subject

PYTHON Write a program that picks up a secret number from 1 to 100 when the user starts the game and asks the
user to guess what number it is. If the user’s guess is correct, the program congratulates the user for the
perfect answer and then make it possible for the user to start a new game; otherwise, it will tell the user
that it is too high or too low and let the user continue to play.
In your program, you may use the following code to generate a random number from 1 to 100 as the
secret number for a new game.
import random
number = random. randint(1, 100)
In addition, your program will keep track of the number of guesses the user made and display the number
of guesses when a game is over. If a user is successful by more than 7 tries, display an additional message
to tell the user to consider a different strategy in order to improve one’s performance.
Given below is a typical dialog between a user and your program when the user uses your program.
Hello, what is your name? John
John, I am thinking a number between 1 and 100 (both included).
Can you guess what it is?
Guess a number (1-100): 50
Your guess is too high. Try again.
Guess a number (1-100): 25
Your guess is too low. Try again.
Guess a number (1-100): 35
Your guess is too low. Try again.
Guess a number (1-100): 43
John, you won in 4 tries. Congratulations!
Do you want to continue to play? no
Thank you for playing this game. Bye.
In the above, the user plays the game only once. If the user says ‘yes’ at the second to last step, he/she
would be able to play the game again.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 06:30
Ineed to know the anwser to all these questions
Answers: 2
question
Computers and Technology, 24.06.2019 11:30
Convert 11001110(acdd notation) into decimal
Answers: 2
question
Computers and Technology, 24.06.2019 20:30
How is energy expended in active transport
Answers: 1
question
Computers and Technology, 24.06.2019 23:50
What is your fav video game currently: a) roblox b) fortnite c) apex legends d) pubg
Answers: 2
You know the right answer?
PYTHON Write a program that picks up a secret number from 1 to 100 when the user starts the game an...
Questions
question
Mathematics, 07.03.2021 01:50
question
Mathematics, 07.03.2021 01:50
question
Mathematics, 07.03.2021 01:50
question
Mathematics, 07.03.2021 01:50
Questions on the website: 13722361