i need help writing a program to roll dice

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenest
    New Member
    • Mar 2007
    • 1

    #1

    i need help writing a program to roll dice

    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!!!
  • ilikepython
    Recognized Expert Contributor
    • Feb 2007
    • 844

    #2
    Originally posted by lenest
    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:
    Code:
    import random
    
    dice1 = random.randint(1, 6)
    dice2 = random.randint(1, 6)
    print dice1, dice2

    Comment

    Working...