a guest Jun 13th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #this program is a game that rolls a dice and allows the user to guess the value that the dice will produce.
- from random import randint
- from time import sleep
- number_of_sides = 6
- def get_user_guess():
- guess = int(raw_input("guess a number:"))
- return guess
- def roll_dice(number_of_sides):
- first_roll = randint(1, number_of_sides)
- second_roll = randint(1, number_of_sides)
- max_val = number_of_sides * 2
- print "The maximum possible value is: %d" % max_val
- guess = get_user_guess()
- if guess > max_val:
- print "invalid"
- print "Rolling...."
- print "The 1st roll is: %d" % first_roll
- print "The 2nd roll is: %d" % second_roll
- total_roll = first_roll + second_roll
- print total_roll
- print "Result...."
- if guess == total_roll:
- print "You have won!!"
- print "you lost!"
RAW Paste Data