Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

=+What sample size would you recommend for this study?

Answered: 1 week ago