Made this game with the help of 6P and prior knowledge from ITE de C# programming
Just a simple guessing game in Python that only requires user to guess a digit from 1 to 99 by just entering the answer they feel is right
The code :
import random
ans = random.randint(1,99)
low = 1
high = 99
temp_low = 0
temp_high = 0
guess = ' '
tries = 1
while (guess != ans):
tries = tries + 1
guess = raw_input("Guess the number between 1 and 99: ")
try:
guess = int(guess)
if guess < 1 or guess > 99:
print "Please enter between 1 to 99"
exit()
except:
print "Invalid Entry, Game Over"
exit()
if guess < ans:
if guess > low:
temp_low = guess
low = guess
if low > temp_low:
low = low
else:
low = temp_low
print "You entered " + `guess`
print "It is HIGHER than " + `low` + " but LOWER than " + `high`
elif guess > ans:
if guess < high:
temp_high = guess
high = guess
if high < temp_high:
high = high
else:
high = temp_high
print "You entered " + `guess`
print "It is HIGHER than " + `low` + " but LOWER than " + `high`
print "Well done!"
print "The answer is "+ `ans` + "!"
print "You took " + `tries` + " tries"
if tries <= 5:
print "Wow, you're really lucky"
if tries > 5 and tries <= 10:
print "Not bad, quite lucky~"
else:
print "Nice effort, you might be luckier on next game!"
Gonna try create Scissor, Paper, Stone game with a similar concept when free