File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ #Letting the computer guess your Number
2
+
3
+ import random
4
+
5
+ def computer_guess (x ):
6
+ low = 1
7
+ high = x
8
+ feedback = ''
9
+ while feedback != 'c' :
10
+ if low != high :
11
+ guess = random .randint (low , high )
12
+ else :
13
+ guess = low # it can be low or high since low == high.
14
+ print ("Please enter (h) If the number guessed by the computer is Higher than your number, (l) If it's Lower and (c) If it's the Correct number.\n " )
15
+ feedback = input (f"Is { guess } , High(h), Low(l), or Correct(c)??\n " )
16
+ if feedback == 'h' :
17
+ high = guess - 1
18
+ elif feedback == 'l' :
19
+ low = guess + 1
20
+
21
+ print (f"Yeahh! Finally the computer guessed your number, { guess } , correctly!" )
22
+
23
+ computer_guess (1000 ) #You can update the value, it's upto you :)
Original file line number Diff line number Diff line change @@ -25,3 +25,5 @@ Feel free to add basic python scripts/programs that helped you learn python. I h
25
25
7 . [ Web Scraping] ( https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Web%20scraping )
26
26
8 . [ Gmail Automation] ( https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Gmail%20automation )
27
27
9 . [ GUI Calculator] ( https://github.com/1-Rishabh-Jain-1/Beginners-Python-Projects/blob/main/gui_calculator.py )
28
+ 10 . [ Higher Lower Game] ( https://github.com/TheTriangulam/Beginners-Python-Projects/tree/main/Num_guess_by_Comp )
29
+ [ Devivaraprasad Rathikindi] ( https://github.com/TheTriangulam )
You can’t perform that action at this time.
0 commit comments