Question: Use Python In this assignment, you will be calculating the average number of guesses it takes for someone to guess a randomly-generated number. In a

 Use Python In this assignment, you will be calculating the average

Use Python

In this assignment, you will be calculating the average number of "guesses" it takes for someone to guess a randomly-generated number.

In a single run of the program, the following will happen:

A random number is generated

The user will be asked to guess the number

The user will be given feedback (their guess is low, high, or correct)

If they guess an incorrect number, then they will be given a chance to guess again. (This process will continue until they guess the correct number.)

If/when they guess the correct number, then the number of guesses they made will be printed out.

The above steps should happen for 5 randomly-generated numbers in the program. Each time the user correctly guesses the number, then the number of guesses should be added to the total number of guesses. After all five "rounds" have been complete (five random numbers, five rounds of guessing), then the program should end, printing out the average number of guesses needed to guess the number.

Please note that I am not looking for one really long program where code is "cut-and-pasted" multiple times. You should be looking to solve this program in a loop, with the solution being ~30 lines of actual code or so. If your solution ends up being 100 lines of code, then you probably approached it wrong.

Write this program out as a flow chart before you start it. Upload a picture of the flowchart as part of your solution (note: PNG, JPG, or PDF).

Deliverables:

- one program (Python file)

- one flowchart (PNG, JPG, or PDF - either handwritten or a screenshot)

How to generate "random" numbers:

We haven't done random numbers in class yet, but the following two lines of code will generate a random number between 0 and 9 (inclusive). Put the first line at the top of your program. The next line can occur anywhere. Feel free to replace the variable "x" with whatever variable you want.

from random import randrange

x = randrange(10)

In this assignment, you will be calculating the average number of "guesses" it takes for someone to guess a randomly-generated number. In a single run of the program, the following will happen: - A random number is generated - The user will be asked to guess the number - The user will be given feedback (their guess is low, high, or correct) - If they guess an incorrect number, then they will be given a chance to guess again. (This process will continue until they guess the correct number.) - If/when they guess the correct number, then the number of guesses they made will be printed out. The above steps should happen for 5 randomly-generated numbers in the program. Each time the user correctly guesses the number, then the number of guesses should be added to the total number of guesses. After all five "rounds" have been complete (five random numbers, five rounds of guessing), then the program should end, printing out the average number of guesses needed to guess the number. Please note that I am not looking for one really long program where code is "cut-and-pasted" multiple times. You should be looking to solve this program in a loop, with the solution being 30 lines of actual code or so. If your solution ends up being 100 lines of code, then you probably approached it wrong. Write this program out as a flow chart before you start it. Upload a picture of the flowchart as part of your solution (note: PNG, JPG, or PDF). Deliverables: - one program (Python file) - one flowchart (PNG, JPG, or PDF - either handwritten or a screenshot) How to generate "random" numbers: We haven't done random numbers in class yet, but the following two lines of code will generate a random number between 0 and 9 (inclusive). Put the first line at the top of your program. The next line can occur anywhere. Feel free to replace the variable " x " with whatever variable you want. from random import randrange x= randrange

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!