[Tutor] Why won't it enter the quiz? (off topic)
Nathan Pinno
falcon3166 at hotmail.com
Sat Sep 17 06:30:17 CEST 2005
Hey all,
It looks like I started another running debate, the last time I did this, it
went forever it seemed.
Any hints or help on that original question?
For clarity, I'll ask it again:
Why won't it enter the quiz? Here is the code again:
{code}
import random
def add(a,b):
answer = a+b
guess = float(raw_input(a," + ",b," = "))
return answer, guess
num1 = random.choice(range(1,10)) ### To limit the numbers chosen from 1-9
num2 = random.choice(range(1,10))
while 1:
q = random.choice(range(15,31)) ### to choose the number of questions
cq = 1 ### To find the current question
correct = 0
while cq >= q: ### To find whether or not to end the quiz.
print cq
answer, guess = 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."
{/code}
Thanks for the help in advance,
Nathan Pinno
----- Original Message -----
> Date: Fri, 16 Sep 2005 22:52:51 -0400
> From: Nathan Coulter <tutor.python.org at pooryorick.com>
> Subject: Re: [Tutor] Why won't it enter the quiz? (off topic)
> Cc: Tutor at python.org
> Message-ID: <432B8503.7080508 at pooryorick.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Byron wrote:
>> Hi Nathan,
>>
>> Wow, I have to give you some good credit -- you are quite the sneaky and
>> innovative business guy. You get the free tutors here to help write
>> your programs and when they are finished, you sell them on your website
>> for $20.00 each! I bet more businesses wish they could do business the
>> way you do! Quite efficient, I must admit... <big grin>
>>
>
> I'd bet that almost EVERYONE on this list is selling software with the
> skills they may have picked up here. There's nothing wrong with that!
> And any of Nathan's customer's that want to try to build it themselves are
> free to look here on the list to see exactly how he did it. Kudos,
> Nathan!
>
> Bye,
> Poor Yorick
>
>
> ------------------------------
More information about the Tutor
mailing list