Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

Students also viewed these Databases questions

Question

What are negative messages? (Objective 1)

Answered: 1 week ago