Skip to content

Instantly share code, notes, and snippets.

@indig0fox
Created March 4, 2018 16:34
Show Gist options
  • Save indig0fox/9c4b62b4af544722a4bcf9a1cefaad0c to your computer and use it in GitHub Desktop.
Save indig0fox/9c4b62b4af544722a4bcf9a1cefaad0c to your computer and use it in GitHub Desktop.
DiceRoll.py
"""This program will allow a user to attempt to guess a randomly generated number."""
from random import randint
from time import sleep
def get_user_guess():
user_guess = int(raw_input("What's your whole-number guess? "))
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 max value will be %s.' % str(max_val))
sleep(1)
user_guess = get_user_guess()
if user_guess > max_val:
print "You guessed higher than is allowed."
return
else:
print "Rolling..."
sleep(2)
print ("The first roll is %d.") % first_roll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment