forked from coder2hacker/Explore-open-source
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuessNumber.py
More file actions
36 lines (29 loc) · 1.23 KB
/
GuessNumber.py
File metadata and controls
36 lines (29 loc) · 1.23 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
import random
input('==================PRESS ENTER TO START THE GAME==================')
print('\n\n\n')
print(' | ||||||||||| | | |||||||| ||||||||| ||||||||| ===============')
print(' | | | | \\ \\ \\ ===============')
print(' | | /|||| | | |||||| \\\\ \\\\ ===============')
print(" | |_____|___| | | // \\\\\\\ \\\\\\\ ===============")
print(" | ||||||||||| \|||||/ |||||||| ||||||||| ||||||||| ===============")
print('\n\n')
points = 0
while True:
Guess = int(input('\rGuess a number between 1 and 60 :'))
num = int(random.random() * 61)
points += abs(Guess - num)
print(f'\rActual number is {num}. You are off by {abs(Guess - num)}\nyour current score is {points}')
ask = input('\rdo you want to play more(y/n): ')
if ask == 'n':
break
# HIGH SCORE
HIGH = open("HIGH SCORE.txt")
highscore = HIGH.readlines()
highscore.append('0')
HIGH.close()
highscore = max(int(highscore[0]), points)
HIGH = open("HIGH SCORE.txt", "w")
HIGH.write(highscore)
HIGH.close()
print(f'Your score is: {points}\nHIGH SCORE: {highscore}')
print('\n')