[Tutor] Will the following code ever exit?

Nathan Pinno falcon3166 at hotmail.com
Sat Sep 17 02:59:06 CEST 2005

Hey all,

Will the following code ever exit, or do I have to change something so that it will exit? It's a sample of what I'm currently working on.
import random

def add(a,b):
    answer = a+b
    guess = float(raw_input(a," + ",b," = "))

num1 = random.choice(range(1,10))
num2 = random.choice(range(1,10))

q = random.choice(range(15,31)
cq = 1
while cq >= q:
    if guess != answer:
        print "Incorrect! The correct answer is: ",answer
        incorrect += 1
        cq += 1
   elif guess == answer:
       print "Correct!"
       correct += 1
       cq += 1
   print "Questions: ",q
   print "Correct: ",correct
   print "Percent Correct: ",(correct/q)*100

Nathan Pinno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050916/4db65435/attachment.htm

More information about the Tutor mailing list