<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2722" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>Hi all,</DIV>
<DIV> </DIV>
<DIV>I've got this program I've written that should give an addition quiz,
except it never enters the quiz. How do I make it enter the quiz?</DIV>
<DIV> </DIV>
<DIV>Here is the code:</DIV>
<DIV>import random</DIV>
<DIV> </DIV>
<DIV>def add(a,b):<BR> answer = a+b<BR>
guess = float(raw_input(a," + ",b," = "))</DIV>
<DIV> </DIV>
<DIV>num1 = random.choice(range(1,10))<BR>num2 =
random.choice(range(1,10))</DIV>
<DIV> </DIV>
<DIV>while 1:<BR> q =
random.choice(range(15,31))<BR> cq = 1<BR>
correct = 0<BR> while cq >=
q:<BR>
add(num1,num2)<BR> if guess !=
answer:<BR>
print "Incorrect! The correct answer is:
",answer<BR>
cq += 1<BR> elif guess ==
answer:<BR>
print
"Correct!"<BR>
correct +=
1<BR> cq +=
1<BR> else:<BR>
print "Questions: ",q<BR> print
"Correct: ",correct<BR> print "Percent
Correct: ",(cq/q)*100<BR> break</DIV>
<DIV> </DIV>
<DIV>print "Goodbye."</DIV>
<DIV> </DIV>
<DIV>It just prints out for an example:</DIV>
<DIV> </DIV>
<DIV>Questions: 17<BR>Correct: 0<BR>Percent Correct:
0<BR>Goodbye.</DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV>Nathan Pinno</DIV></BODY></HTML>