subject

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 linesdef 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 tookmain() 
 
Part 2: Test Your Code  
1Use the Python IDLE to test the program. 
2Using comments, type a heading that includes your name, today’s date, and a short description. 
3Run 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.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
What is the term for water wave that is created by an underwater earthquake
Answers: 1
question
Computers and Technology, 24.06.2019 22:10
In command prompt, whats a command that will list only .ini files in c: \windows\system32 directory?
Answers: 1
question
Computers and Technology, 25.06.2019 00:30
You are to write a series of steps that anyone could follow to solve the following three problems: 1. even odd a. assume that someone tells you a number (an integer number) b. you hear the number and respond with the word even or odd 2. average a. assume that someone tells you between 3 and 5 numeric values. b. you hear the numbers and respond with the average is some number 3. dog or cat a. explain to a child the differences between a dog and a cat. b. your explanation could be used by a child or anyone to distinguish the difference between a dog and a cat
Answers: 1
question
Computers and Technology, 25.06.2019 04:30
He 98 pointsss how has computers changed over the years? how can they be used now? give details and such!
Answers: 1
You know the right answer?
Output: Your goal  You will complete a program that asks a user to guess a number.  
 
 
Questions
question
Mathematics, 23.07.2020 03:01
Questions on the website: 13722367