Python Forum
Help with the excercise
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with the excercise
#1
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)
Reply
#2
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?
Reply
#3
(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
Reply
#4
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 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Program excercise SushiRolz 1 2,468 Feb-28-2018, 01:48 AM
Last Post: Larz60+
  excercise python list Kykoss 7 4,011 Feb-11-2018, 03:08 PM
Last Post: DeaD_EyE
  Homework-excercise gmit01 2 2,716 Dec-11-2017, 08:39 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020