Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions