Question: Python 3 Question : add 3 define function at least one to take parameter and one needs to return a value. please send me a
Python 3
Question : add 3 define function at least one to take parameter and one needs to return a value. please send me a new version of my code please and thanks.
fix error code "ZeroDivisionError:
name = input (" Enter your name: ") print ("Hello " + name + " Do you want to take the quiz?!") x = int(input("Y for 1 or N for 2: ")) if x == 1 : print ("In this quiz i will promt 15 math questions") elif x == 2 : quit() import random questions = {} score = 0 for i in range (15): int_f = random.randint(0,10) int_s = random.randint(0,10) operators = ['%','*','/','**'] operator_value = random.choice(operators) question = str(int_f)+' '+str(operator_value)+' '+str(int_s) answer = eval(question) question+=': ' questions.update({question:str(answer)}) for q in questions.keys(): user_answer = input(q) if questions.get(q) == str(user_answer): score+=1 print('correct') else: print('incorrect') print('you got '+str(score)+' /15!')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
