Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Function that simulates a pair of dice being rolled n times and
- # returns the number of occurrences of each score.
- #Possible results:
- #(1,1) (1,2) (1,3) (1,4) (1,5) (1,6)
- #(2,1) (2,2) (2,3) (2,4) (2,5) (2,6)
- #(3,1) (3,2) (3,3) (3,4) (3,5) (3,6)
- #(4,1) (4,2) (4,3) (4,4) (4,5) (4,6)
- #(5,1) (5,2) (5,3) (5,4) (5,5) (5,6)
- #(6,1) (6,2) (6,3) (6,4) (6,5) (6,6)
- import random
- def throw_dice(game):
- if game == "yes":
- n1 = random.randint(1,6)
- n2 = random.randint(1,6)
- print("The result of dice one is " + str(n1) + " and the dice two is " +str(n2))
- print("The sum of the two dice thrown is " + str(n1+n2))
- return
- # main
- print("Let's roll the dice!")
- # loop
- finished = False
- while finished == False:
- game = input("Do you want to throw the dice? yes/no: ")
- if game == "yes":
- throw_dice(game)
- else:
- print("The answer has been... " + game + " , then bye.")
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement