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, 22.06.2019 18:40
Mariah was working on a multimedia presentation that included both video and audio files. the file was huge, and she wanted to send it to her coworker in another office. she needed to reduce the size of the file so that it could be transmitted faster. the utility she used to do this was
Answers: 2
question
Computers and Technology, 22.06.2019 22:40
When you type the pwd command, you notice that your current location on the linux filesystem is the /usr/local directory. answer the following questions, assuming that your current directory is /usr/local for each question. a. which command could you use to change to the /usr directory using an absolute pathname? b. which command could you use to change to the /usr directory using a relative pathname? c. which command could you use to change to the /usr/local/share/info directory using an absolute pathname? d. which command could you use to change to the /usr/local/share/info directory using a relative pathname? e. which command could you use to change to the /etc directory using an absolute pathname? f. which command could you use to change to the /etc directory using a relative pathname?
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Which of the following would not be considered a pc? a. mainframe b. desktop c. tablet pc d. laptop
Answers: 2
question
Computers and Technology, 23.06.2019 22:00
Jackson, who works in the finance department of a company, is holding a seminar for other employees on how to file taxes. only three employees sign up to attend the seminar. which device can he use to share his presentation with a group of three employees?
Answers: 1
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
Chemistry, 25.10.2020 01:00
question
Chemistry, 25.10.2020 01:00
question
Computers and Technology, 25.10.2020 01:00
question
Chemistry, 25.10.2020 01:00
question
Mathematics, 25.10.2020 01:00
question
Mathematics, 25.10.2020 01:00
question
Mathematics, 25.10.2020 01:00
Questions on the website: 13722363