Python Forum
Help with the excercise - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Help with the excercise (/thread-26038.html)



Help with the excercise - alani - Apr-19-2020

Hi!
I'm having a hard time trying to deal with this exercise. I have to create a program that should ask you 10 times about a product of the equation form multiplication table. Also in the end, it should print how many correct and wrong answers there were, as also the percentage of correct ones. And actually I've no idea how to program this code
to show the numbers of correct given products and wrong ones. I would much appreciate any help! And this's what I've managed to do for now:
from random import*

odp=True
s=0

while odp==True or odp==False:
    a=randint(1,10)
    b=randint(1,10)
    c=a*b

    print("what's the answer of",a,"*",b,end="")
    d=int(input())
    if c==d:
        odp=True
        s=s+1
    elif c!=d:
        odp=False
        s=s+1
    if s>10:
        break
        
      
print("number of correct answers-",s)
print("number of wrong answers-",10-s)
print("precentage of correct ones-",s*10)



RE: Help with the excercise - deanhystad - Apr-19-2020

Do you get 10 guesses or 10 incorrect guesses? When the player guesses incorrectly do they get to try solving the same equation again, or is a new equation generated after each guess?


RE: Help with the excercise - alani - Apr-19-2020

(Apr-19-2020, 04:43 PM)deanhystad Wrote: Do you get 10 guesses or 10 incorrect guesses? When the player guesses incorrectly do they get to try solving the same equation again, or is a new equation generated after each guess?
The new equation is generated after each guess, and it should break after 10 questions


RE: Help with the excercise - deanhystad - Apr-19-2020

correct = 0
for _ in range(10):
    # Present equation.  You already have this
    # Read input. You already have this
    # TODO if guess is correct
    #           increment correct answer counter
# TODO: Calculate % of correct answers