Question
Task two- A math quiz program Program a math quiz that consists of five questions. Only one question is asked at each step. Each question
Task two- A math quiz program Program a math quiz that consists of five questions. Only one question is asked at each step. Each question is made by randomly generating two whole numbers (integers) for an addition operation: numl + num2. After presenting the question to the user, ask them to enter the answer.
If the answer is correct, add a point to the total score.
At the end of the quiz, display the total score they got correct out of five.
The statements for generating random numbers inside a range are given in the code cell next.
In [3]: import random num1 = random.randint(1,100) num2 = random.randint(1, 100) print(numi, num2) 73 65 In [ ]: # add your codes here import random totalScore = 0 for i in range(5): num1 = random.randint(1,100) num2 = random.randint(1,100) print(num1,\"+\", num2,\"= \", end=\"\") userAnswer = int(input()) if userAnswer==(num1+num2): totalScore += 1 print(\"Total score out of 5 is\", totalScore) 26 + 98 = 3.
[10pts] Task three - Do it differently There are two iteration types in Python, for and while.
Now use a different iteration type from the previous task to complete the same job. In [*]: | In [ ]:
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