I want to write a very simple number guessing game for my girlfriend by Python. Yet I believe that it is a quite logical problem so anyone who doesn't know Python can also read this! This game is quite standard: computer randomly choose a number and ask the user to guess. Here is my code:
while True:
from random import randint
ans = randint(1,100)
print "Guess from 1 to 100"
bool = True
while bool:
num = input()
if num < ans:
print str(num) + " is too small!"
if num > ans:
print str(num) + " is too BIG!"
if num == ans:
print "Bingo! %d is what I am thinking!" % num
print "Try again =]"
for i in range(0,40):
print '*',
print
bool = False
However, I want to add a few of new functions into it:
I know that it is a hard question but that is an important gift for my girlfriend so I will be really really appreciate it if anyone can help. Python code is not a must for me so if anyone can answer my third question by just telling me the algorithm, I think that I can work the code out by myself. Thank everyone who reads this!