Skip to content

Commit 52bc733

Browse files
authored
Merge pull request Aishanipach#2 from TheTriangulam/main
Number guess by Computer
2 parents 31e7ea0 + ce54298 commit 52bc733

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Num_guess_by_Comp/num_guess.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 :)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ Feel free to add basic python scripts/programs that helped you learn python. I h
2525
7. [Web Scraping](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Web%20scraping)
2626
8. [Gmail Automation](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Gmail%20automation)
2727
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)

0 commit comments

Comments
 (0)