subject

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()

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
What can tanya do now to start preparing for the college and scholarship application process? think about her grades, activities in which she can get involved, possible part-time jobs at which she can work, and standardized tests she can take. (10 points) apex
Answers: 2
question
Computers and Technology, 22.06.2019 11:30
Awell-diversified portfolio needs about 20-25 stocks from different categories is this true or false?
Answers: 2
question
Computers and Technology, 22.06.2019 14:30
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
question
Computers and Technology, 23.06.2019 06:20
Which text function capitalizes the first letter in a string of text? question 10 options: upper capital first proper
Answers: 1
You know the right answer?
You will complete a program that asks a user to guess a number. Part 1: Review the Code
Revi...
Questions
question
Mathematics, 19.06.2021 01:30
question
Social Studies, 19.06.2021 01:30
question
English, 19.06.2021 01:30
question
Mathematics, 19.06.2021 01:30
Questions on the website: 13722361