[Tutor] Loop help

Cameron Stoner wolf_binary@hotmail.com
Sun, 7 Apr 2002 13:23:57 -0500


It just dawned on me that you need to test it 10 times too.
Look down at your code and you will see what I mean.
----- Original Message -----
From: "Darren Anthony" <dtanthony@earthlink.net>
To: <tutor@python.org>
Sent: Sunday, April 07, 2002 11:54 AM
Subject: [Tutor] Loop help


> 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
#while x <= 10:
#    x = x + 1
>    r=read_number()
>    z=x*y
>    if z==r:
>        print "That's right --well done"
>    else:
>        print "No, I'm afraid the answer is"
#end of loop
> print z
>
>
> raw_input("Press return to exit: ")
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>