Need help on program!!!

D

Darth Haggis

I need help writing a program....

You are to write a python program to accomplish the following:



a.. Play a dice game of Craps using a random number generator to simulate
the roll of the dice, the code for the rolling of the dice should take place
in a user written module named rolldice.
b.. The rules of the game are as follows:
a.. 1st roll, a score of 7 or 11 wins.
b.. 1st roll, a score of 2, 3, or 12 loses.
c.. 1st roll, any number other than those listed above becomes the goal
number, you must keep rolling until you roll the goal number again. If a 7
is rolled before you goal number, you lose.


Make the game continuous, until you tell it to stop. You can bet the same
amount, or change you bet after each win or loss. Print the results of each
roll and the running total of winnings or loses.



plz help!!!



Haggis
 
D

Dan Perl

That was also my impression. Even the description of the problem looks like
it's just copied from the assignment, so probably didn't even take the time
to restate the problem in his own words.

But we're speculating. Either way, this is not a normal request: "I need a
program to do this, plz help!" To the OP: you can't seriously expect us to
actually write the program for you, what kind of help are you looking for?

Dan
 
M

Max M

Dan said:
That was also my impression. Even the description of the problem looks like
it's just copied from the assignment, so probably didn't even take the time
to restate the problem in his own words.

But we're speculating. Either way, this is not a normal request: "I need a
program to do this, plz help!" To the OP: you can't seriously expect us to
actually write the program for you, what kind of help are you looking for?

This?


# -*- coding: latin-1 -*-

"""
a.. Play a dice game of Craps using a random number generator to simulate
the roll of the dice, the code for the rolling of the dice should take place
in a user written module named rolldice.

b.. The rules of the game are as follows:
a.. 1st roll, a score of 7 or 11 wins.
b.. 1st roll, a score of 2, 3, or 12 loses.
c.. 1st roll, any number other than those listed above becomes the goal
number, you must keep rolling until you roll the goal number again. If a 7
is rolled before you goal number, you lose.
"""

import random

def rolldice():
dice1, dice2 = random.randint(1,6), random.randint(1,6)
print dice1, dice2
return dice1, dice2

first1, first2 = rolldice()
first = first1, first2
roll = 1
if first in (7, 11):
print 'Congratulations, you win in roll %s' % roll
elif first in (2,3,7):
print 'Too bad, you loose in roll %s' % roll
result = 'draw'
while result == 'draw':
dice1, dice2 = rolldice()
roll += 1
if dice1 + dice2 == 7:
print 'Too bad, you loose in roll %s' % roll
result = None
elif (dice1, dice2) == (first1, first2):
print 'Congratulations, you win in roll %s' % roll
result = None


Hopefully his teacher doesn't know about Google, or he can be expelled
from school for using it.

--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
 
G

Grant Edwards

That was also my impression. Even the description of the
problem looks like it's just copied from the assignment, so
probably didn't even take the time to restate the problem in
his own words.
[...]

Hopefully his teacher doesn't know about Google, or he can be
expelled from school for using it.

And there's always the chance the somebody intentionally posted
a wrong answer just to teach somebody a lesson. I'm not
accusing Max of this, but I've seen it done in the past.
 
D

Dan Perl

Max M said:
Hopefully his teacher doesn't know about Google, or he can be expelled
from school for using it.

"Hopefully" for whom? For us, who may have to work with him someday or use
a product that he developed? Most of us here have been students (or still
are) and may sympathize with the OP, but personally I have been also a TA so
I have seen the other side and that's where my sympathy lies now.

Dan
 
J

Jerry Sievers

Darth Haggis said:
I need help writing a program....

You are to write a python program to accomplish the following:

a.. Play a dice game of Craps using a random number generator to simulate
the roll of the dice, the code for the rolling of the dice should take place
in a user written module named rolldice.

[snip]

I'll have this ready for you Monday AM.

Contact me for PayPal instructions!

Your Professor won't have a clue. I'll even do it in an inefficient
way so's to make it look like done by a stressed out student.

HTH
 
B

Brad Tilley

Grant said:
That was also my impression. Even the description of the
problem looks like it's just copied from the assignment, so
probably didn't even take the time to restate the problem in
his own words.

[...]


Hopefully his teacher doesn't know about Google, or he can be
expelled from school for using it.


And there's always the chance the somebody intentionally posted
a wrong answer just to teach somebody a lesson. I'm not
accusing Max of this, but I've seen it done in the past.

Perhaps Max teaches the class ;)
 
M

Max M

Dan said:
"Max M" <[email protected]> wrote in message
Most of us here have been students (or still
are) and may sympathize with the OP, but personally I have been also a TA so
I have seen the other side and that's where my sympathy lies now.

My reply was a joke... My normal response has allways been "why should
we do your homework for you,"

So I just turned it upside down. "Naturally I will do homework for
random users on usenet. here it is."

I simply found the idea of asking for homework cheats on usenet, where
it can be traced very easily... well not very clever.

> "Hopefully" for whom? For us, who may have to work with him someday or use
> a product that he developed?

I have a feeling that this guy has a future in IT. He definitely has
management potential.

--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
 
B

Brad Tilley

Darth said:
I need help writing a program....

You are to write a python program to accomplish the following:



a.. Play a dice game of Craps using a random number generator to simulate
the roll of the dice, the code for the rolling of the dice should take place
in a user written module named rolldice.
b.. The rules of the game are as follows:
a.. 1st roll, a score of 7 or 11 wins.
b.. 1st roll, a score of 2, 3, or 12 loses.
c.. 1st roll, any number other than those listed above becomes the goal
number, you must keep rolling until you roll the goal number again. If a 7
is rolled before you goal number, you lose.


Make the game continuous, until you tell it to stop. You can bet the same
amount, or change you bet after each win or loss. Print the results of each
roll and the running total of winnings or loses.



plz help!!!

Here's everything *except* the betting part. I don't gamble ;)

import random

class rolldice:

def first(self):

win = [7,11]
lose = [2,3,12]
x = random.randint(1,6)
y = random.randint(1,6)
z = x+y
print x, "+", y, "=", z
if z in win:
print "You won on the first roll!!!"
return 0
elif z in lose:
print "You lost on the first roll!!!"
return 0
else:
return z

def second(self, goal):

if goal > 0:
lose = 7
print "The goal number is:", goal

while True:
x = random.randint(1,6)
y = random.randint(1,6)
z = x+y
print x, "+", y, "=", z
if z == lose:
print "You lost!!!"
return 0
elif z == goal:
print "You won!!!"
return z
else:
continue

play = rolldice()
play.second(play.first())
 
B

Brad Tilley

Max said:
This?


# -*- coding: latin-1 -*-

"""
a.. Play a dice game of Craps using a random number generator to simulate
the roll of the dice, the code for the rolling of the dice should take
place
in a user written module named rolldice.

b.. The rules of the game are as follows:
a.. 1st roll, a score of 7 or 11 wins.
b.. 1st roll, a score of 2, 3, or 12 loses.
c.. 1st roll, any number other than those listed above becomes the goal
number, you must keep rolling until you roll the goal number again. If a 7
is rolled before you goal number, you lose.
"""

import random

def rolldice():
dice1, dice2 = random.randint(1,6), random.randint(1,6)
print dice1, dice2
return dice1, dice2

first1, first2 = rolldice()
first = first1, first2
roll = 1
if first in (7, 11):
print 'Congratulations, you win in roll %s' % roll
elif first in (2,3,7):

I think you mean 'elif first in (2,3,12):'
 
D

Dan Perl

Miklós P said:
To me, it's my benignity towards the OP rather than my sympathy to the
TAs...
That's why I find the greedy guy's offer immoral.

I'm not sure what you mean by "benignity" here, but I think I agree with
you. Sympathy for TAs is not really my reason for how I feel towards
someone cheating on their assignment. I was just looking for something to
oppose sympathy for a student (assuming that sympathy was the only possible
reason to give him the solution). I guess that is not the best argument I
could have made.

Dan
 
M

Miklós P

Darth Haggis said:
I need help writing a program....

You are to write a python program to accomplish the following:
....


Haggis

Seems very much like homework to me... ;) And that's something you are
supposed to do on your own..

M.
 
M

Miklós P

Dan Perl said:
"Hopefully" for whom? For us, who may have to work with him someday or use
a product that he developed? Most of us here have been students (or still
are) and may sympathize with the OP, but personally I have been also a TA so
I have seen the other side and that's where my sympathy lies now.

Dan

To me, it's my benignity towards the OP rather than my sympathy to the
TAs...
That's why I find the greedy guy's offer immoral.

Best regards,
Miklós
 
M

Miklós P

Dan Perl said:
I'm not sure what you mean by "benignity" here, but I think I agree with
you. Sympathy for TAs is not really my reason for how I feel towards

I meant that I think the real (or long term) interest of the OP is to
*learn* things as opposed to
(the short term interest in) submitting that homework without his devoting
any effort.
reason to give him the solution). I guess that is not the best argument I
could have made.

Dan

Yes, I agree and I had thought you actually meant it similarly like I do.

Best regards,
Miklós
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,212
Messages
2,571,102
Members
47,698
Latest member
TerraT521

Latest Threads

Top