-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnumberGame.py
More file actions
63 lines (41 loc) · 1.43 KB
/
Copy pathnumberGame.py
File metadata and controls
63 lines (41 loc) · 1.43 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#This is a random Number guessing game...
#Made with the use of functions
import random as r
# a=max_count, b=sol max=highest chance
def guess(a,b,max):
c=r.randint(0,max)
count=1
while count<=a and b!=c:
attempt=str(count+1)
if b>c:
print("Lower number ")
b=int(input("Take your guess >> "))
elif b<c:
print("Higher number")
b=int(input("Take your guess >> "))
count+=1
if b==c and count<=a:
print("You Won..!\nYou guessed in "+attempt+" attempts")
elif count>a:
actual=str(c)
print("\nThe number was "+actual+" ")
print("\nYou Lost..Exceeded maximum attempts\nBetter Luck next time")
print("Number Game \n")
print("1.Easy (b/w 0 & 200) 30-Chances\n2.Medium (b/w 0 & 700) 25-Chances\n3.Difficult (b/w 0 & 1000) 20-Chances\n4.Hard (b/w 0 & 3000) 15-Chances")
num=int(input("Enter your choice >> "))
if num>=1 and num<=4:
print("\nGame starts.. Enjoy it ....\n")
if num==1:
sol=int(input("Take your guess >> "))
guess(30,sol,200)
elif num==2:
sol=int(input("Take your guess >> "))
guess(25,sol,700)
elif num==3:
sol=int(input("Take your guess >> "))
guess(20,sol,1000)
elif num==4:
sol=int(input("Take your guess >> "))
guess(15,sol,3000)
else:
print("Invalid choice..Restart the game")