-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberGuess.py
More file actions
35 lines (29 loc) · 946 Bytes
/
NumberGuess.py
File metadata and controls
35 lines (29 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from random import randint
from time import sleep
def get_user_guess():
guess = int(input("Please enter your guess: "))
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("Your guess is invalid")
else:
print("Rolling...")
sleep(2)
print("the first roll is %d" % first_roll)
sleep(2)
print("the second roll is %d" % second_roll)
sleep(2)
total_roll = first_roll + second_roll
print("The total roll is %d" % total_roll)
print("Result....")
sleep(2)
if total_roll == guess:
print("congrats you have won")
else:
print("you have lost. good luck next time!")
roll_dice(6)