cscode
cscode
tries = 1
Upper_limit = int(input("ENTER UPPER LIMIT : "))
Lower_limit = int(input("ENTER LOWER LIMIT : "))
name = input("ENTER NAME :- ")
score = 0
while tries <= 10:
r = random.randint(Lower_limit, Upper_limit)
num = int(input("Guess a number :-"))
if r == num:
score = score + 20
print("THY WIN")
elif r != num:
score = score - 10
print("THY LOSE")
tries = tries + 1
print("YOUR SCORE IS :-", score)
if score == 200:
print("YOU MAY SAY THAT YOU ARE THE PERFECT HUMAN BEING !!!!!")
elif score == 170:
print("JUST THIS CLOSE !!!!!!")
elif score == 140:
print("NICE!!")
elif score == 110:
print("SATISFACTORY RESULT")
elif score == 80:
print("YOU STILL NEED TO LEARN ALOT .")
elif score == 50:
print("BREAKING EVEN NOW , AREN'T WE ?")
elif score == 20:
print("You are there yet!!!")
elif score == -10:
print("WHY , TRY HARDER!")
elif score == -40:
print("YOU DELIBERATELY LOST RIGHT?!")
elif score == -70:
print("ON THE BRIGHTER SIDE YOU STILL GOT 1 CORRECT.")
else:
print("FATE WANTS YOU TO LOSE , TRY AGAIN AND DEFEAT THY FATE.")
def add_data():
f = open("SCORES.txt", "a+")
f.write(name + "," + str(score) + "\n")
f.close()
add_data()
def printallscores():
f = open("SCORES.txt", "r")
t = f.readlines()
for i in t:
print(i)
f.close()
def printsinglescore():
f = open("SCORES.txt", "r")
o = input("ENTER NAME :- ")
p = -1
t = f.readlines()
for i in t:
data2= i.split(",")
if data2[0] == o:
print(data2[0], "scored", data2[1])
p = 1
if p == -1:
print("You did not play the game my friend as there is no record of the
name provided !")
f.close()