Question
*Can you check this code* having problems while running it? import random def questions(): name=input(What is your name:) print(Hello there,name,!) choice = random.choice(+-x) finish =
*Can you check this code* having problems while running it?
import random
def questions(): name=input("What is your name:") print("Hello there",name,"!")
choice = random.choice("+-x") finish = False questionnumber = 0 correctquestions = 0
while finish == False: if questionnumber < 10 | questionnumber >= 0: number1 = random.randrange(1,10) number2 = random.randrange(1,10) print((number1),(choice),(number2)) answer=int(input("What is the answer?")) questionnumber = questionnumber + 1
if choice==("+"): realanswer = number1+number2 if answer==realanswer: print("That's the correct answer") correctquestions = correctquestions + 1 else: print("Wrong answer, the answer was",realanswer,"!")
if choice==("x"): realanswer = number1*number2 if answer==realanswer: print("That's the correct answer") correctquestions = correctquestions + 1 else: print("Wrong answer, the answer was",realanswer,"!")
elif choice==("-"): realanswer = number1-number2
if answer==realanswer: print("That's the correct answer") correctquestions = correctquestions + 1 else: print("Wrong answer, the answer was",realanswer,"!") else: finish = True else: print("Good job",name,"! You have finished the quiz")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started