Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) using random in python, generate two numbers randomly (between 0 and 100) and ask the user to guess the sum of the two numbers.

1) using "random" in python, generate two numbers randomly (between 0 and 100) and ask the user to guess the sum of the two numbers. If the answer was correct you should generate two other random numbers but this time the starting value will be the sum of the two numbers that was generated and the ending value will be 100 * 2 (which the ending value * 2). The next time the user is wrong and answers incorrectly you should go back to the random values between 0 and 100. The rounds for this game is 6 times. Each time you show the answer to the user. This would be the output of the game for instance:

Let's say computer randomly generated 2 and 35.

You would show something like this: 2 + 35 = ? If user enters 37 then you would generate two other values, this time it would be between 35 and 200. Let's say it generated 80 and 145 you would show something like:

80 + 145 = ? If user enters 225 then you would generate two other values, this time it would be between 255 and 400 and you would continue. But let's say the user didn't add the two numbers correctly and entered something like 220. This time you would note "Oops sorry, 220 is not the right answer. The correct answer is 225; Let's try something simpler" then you would generate the two values between 0 and 100 again. This continues for 6 times. After that they are out of this game.

NOTE:You should only use "while" loop for this question. For random use the function randrange(start, end) [for example random.randrange(0, 100)]. You should calculate the sum in backend and store it so that you can check it with what user gave you. Each time the user answers correctly the ending value gets doubles. Meaning if the user answers everything correctly the ending values are going to be 100, 200, 400, 800, 1600, 3200 for all 6 times.

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions