Hi all,
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?
Here is the code:
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)) while 1:
q = random.choice(range(15,31)) cq = 1 correct = 0 while cq >= q: add(num1,num2) if guess != answer: print "Incorrect! The correct answer is: ",answer cq += 1 elif guess == answer: print "Correct!" correct += 1 cq += 1 else: print "Questions: ",q print "Correct: ",correct print "Percent Correct: ",(cq/q)*100 break print "Goodbye."
It just prints out for an example:
Questions: 17
Correct: 0 Percent Correct: 0 Goodbye. Thanks,
Nathan Pinno
|
BEGIN:VCARD VERSION:2.1 N:Pinno;Nathan;Paul;Mr. FN:Pinno, Nathan Paul NICKNAME:Spam_swatter ORG:Woffee;Executive TITLE:Owner/operator TEL;WORK;VOICE:7806085529 TEL;CELL;VOICE:7806085529 ADR;WORK:;President/CEO;Box 1783;Camrose;Alberta;T4V1X7;Canada LABEL;WORK;ENCODING=QUOTED-PRINTABLE:President/CEO=0D=0ABox 1783=0D=0ACamrose, Alberta T4V1X7=0D=0ACanada ADR;HOME:;;Box 1783;Camrose;Alberta;T4V1X7;Canada LABEL;HOME;ENCODING=QUOTED-PRINTABLE:Box 1783=0D=0ACamrose, Alberta T4V1X7=0D=0ACanada X-WAB-GENDER:2 URL;HOME:http://falcon3166.tripod.com URL;WORK:http://zoffee.tripod.com BDAY:19850221 EMAIL;PREF;INTERNET:[EMAIL PROTECTED] EMAIL;INTERNET:[EMAIL PROTECTED] EMAIL;INTERNET:[EMAIL PROTECTED] EMAIL;INTERNET:[EMAIL PROTECTED] REV:20050917T011836Z END:VCARD
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor