[Tutor] Loop help
Darren Anthony
dtanthony@earthlink.net
Sun, 7 Apr 2002 09:54:38 -0700
I'm trying to write a simple times-table testing program.
The program generates two random numbers and multiplies them and ask the
user for the answer. The user inputs answer and the program verifies the
answer. I want to write a loop into the program to ask 10 questions and then
end. How do I create the loop and what line do I place the code?
I'm using python for windows.
Here is my code:
from livewires import*
x = random_between(1,10)
y = random_between(1,10)
s = "What is %d times %d?" % (x,y)
print s
r=read_number()
z=x*y
if z==r:
print "That's right --well done"
else:
print "No, I'm afraid the answer is"
print z
raw_input("Press return to exit: ")