subject

**GIVING ALL POINTS** 4.02 Coding With Loops I NEED THIS TO BE DONE FOR ME AS I DONT UNDERSTAND HOW TO DO IT. THANK YOU

Output: Your goal

You will complete a program that asks a user to guess a number.

Part 1: Review the Code

Review the code and locate the comments with missing lines (# Fill in missing code). Copy and paste the code into the Python IDLE. Use the IDLE to fill in the missing lines of code.

On the surface this program seems simple. Allow the player to keep guessing until he/she finds the secret number. But stop and think for a moment. You need a loop to keep running until the player gets the right answer.

Some things to think about as you write your loop:

The loop will only run if the comparison is true.

(e. g., 1 < 0 would not run as it is false but 5 != 10 would run as it is true)

What variables will you need to compare?

What comparison operator will you need to use?

# Heading (name, date, and short description) feel free to use multiple lines

def main():

# Initialize variables

numGuesses = 0

userGuess = -1

secretNum = 5

name = input("Hello! What is your name?")

# Fill in the missing LOOP here.

# This loop will need run until the player has guessed the secret number.

userGuess = int(input("Guess a number between 1 and 20: "))

numGuesses = numGuesses + 1

if (userGuess < secretNum):

print("You guessed " + str(userGuess) + ". Too low.")

if (userGuess > secretNum):

print("You guessed " + str(userGuess) + ". Too high.")

# Fill in missing PRINT statement here.

# Print a single message telling the player:

# That he/she guessed the secret number

# What the secret number was

# How many guesses it took

main()

Part 2: Test Your Code

Use the Python IDLE to test the program.

Using comments, type a heading that includes your name, today’s date, and a short description.

Run your program to ensure it is working properly. Fix any errors you observe.

Example of expected output: The output below is an example of the output from the Guess the Number game. Your specific results will vary based on the input you enter.

Output

Your guessed 10. Too high.

Your guessed 1. Too low.

Your guessed 3. Too low.

Good job, Jax! You guessed my number (5) in 3 tries!

When you've completed filling in your program code, save your work by selecting 'Save' in the Python IDLE.

When you submit your assignment, you will attach this Python file separately.

Part 3: Post Mortem Review (PMR)

Using complete sentences, respond to all the questions in the PMR chart.

Review Question Response

What was the purpose of your program?

How could your program be useful in the real world?

What is a problem you ran into, and how did you fix it?

Describe one thing you would do differently the next time you write a program.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 20:20
Sometimes writers elaborate on the truth when recalling past events so they can enhance their narrative essay with more interesting descriptions. do you feel that published writers should or should not embellish real life events just to make their stories more interesting?
Answers: 2
question
Computers and Technology, 22.06.2019 17:30
Rachel completed typing an official document with a word processing program. she wants to make sure that her document has no typographical errors. she also wants all headings to have the same font. which features in a word processing program should she use? rachel should use the feature in a word processing program to find typographical errors. she should apply to have uniform headings.
Answers: 1
question
Computers and Technology, 22.06.2019 20:40
Assume that there is a 4% rate of disk drive failure in a year. a. if all your computer data is stored on a hard disk drive with a copy stored on a second hard disk drive, what is the probability that during a year, you can avoid catastrophe with at least one working drive? b. if copies of all your computer data are stored on three independent hard disk drives, what is the probability that during a year, you can avoid catastrophe with at least one working drive?
Answers: 1
question
Computers and Technology, 23.06.2019 00:10
My has been slow anyone else’s ?
Answers: 1
You know the right answer?
**GIVING ALL POINTS** 4.02 Coding With Loops I NEED THIS TO BE DONE FOR ME AS I DONT UNDERSTAND HOW...
Questions
question
Mathematics, 18.03.2021 02:20
question
Mathematics, 18.03.2021 02:20
question
Mathematics, 18.03.2021 02:20
question
Social Studies, 18.03.2021 02:20
question
Mathematics, 18.03.2021 02:20
question
Biology, 18.03.2021 02:20
question
Mathematics, 18.03.2021 02:20
Questions on the website: 13722363