-
Notifications
You must be signed in to change notification settings - Fork 6
/
Number_Guess.py
31 lines (28 loc) · 971 Bytes
/
Number_Guess.py
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
#Number guesser
from random import randint #to generate random numbers
import sys #to include exit()
import time #to include sleep()
rand_num = randint(1,10)
#print(rand_num)
count = 0
while(1):
count = count + 1
n = int(input('Enter the Number[1-10]: '))
if(rand_num == n):
print('You Guessed it Correctly!!!. Number is: {}'.format(n))
print('You did it in {} chances.'.format(count))
time.sleep(3)
choice = input('Do you want to continue ? (y/n):' )
if choice == 'n' or choice == 'N':
sys.exit()
elif choice == 'y' or choice == 'Y':
count = 0
rand_num = randint(1,10)
else:
print('Enter either n/y. Program Exiting..')
time.sleep(1.500)
sys.exit()
elif(n < rand_num):
print('Too Low! Enter a number greater.')
else:
print('Too High! Enter a number Lower.')