By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,002 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,002 IT Pros & Developers. It's quick & easy.

i need help writing a program to roll dice

P: 1
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!!!
Mar 29 '07 #1
Share this Question
Share on Google+
1 Reply


ilikepython
Expert 100+
P: 844
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!!!
We cannot write the whole thing for you but for the dice use something like:
Expand|Select|Wrap|Line Numbers
  1. import random
  2.  
  3. dice1 = random.randint(1, 6)
  4. dice2 = random.randint(1, 6)
  5. print dice1, dice2
  6.  
Mar 29 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.