Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Why doesn't the following program enter the quiz?
Why doesn't the following code enter the quiz?
answer = a+b
guess = float(raw_input(a," + ",b," = "))
return answer, guess
num1 = random.choice(range(1,10))
num2 = random.choice(range(1,10))
q = random.choice(range(15,31))
cq = 1
correct = 0
while cq >= q:
answer, guess = add(num1,num2)
if guess != answer:
print "Incorrect! The correct answer is: ",answer
cq += 1
elif guess == answer:
correct += 1
cq += 1
print "Questions: ",q
print "Correct: ",correct
print "Percent Correct: ",(cq/q)*100
Here is a sample output when I run it:
Percent Right: 0
How do I make it enter the quiz?
Swat spam before it fills your inbox!
0 · ·