Created
August 16, 2017 21:12
-
-
Save khayyamsaleem/634316e24bece62d5a8cb476ee15a59d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This is a guessing game about rolling dice, summing the total and comparing to a guess. HOPKINS August 16th, 2017""" | |
from random import randint | |
from time import sleep | |
def get_user_guess(): | |
user_guess = int(raw_input("Guess a number between 2 and 12")) | |
return user_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 sum will be " + str(max_val) | |
sleep(1) | |
user_guess = get_user_guess() | |
if user_guess>max_val: | |
print "Your guess is too big" | |
else: | |
print "Rolling" | |
sleep(2) | |
print "Your first roll was a %d" % first_roll | |
sleep(1) | |
print "Your second roll was a %d" % second_roll | |
sleep(1) | |
total_roll = first_roll + second_roll | |
print "And the result is %d" % total_roll | |
sleep(1) | |
if user_guess>total_roll: | |
print "Hey dog, you won!" | |
return | |
elif user_guess<total_roll: | |
print "I'm sorry, you lost this round" | |
return | |
roll_dice(6) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment