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 15:10
Consider a direct-mapped cache with 216 words in main memory. the cache has 16 blocks of 8 words each. it is a word-addressable computer (rather than a byte-addressable computer which we normally discuss). (a) how many blocks of main memory are there? (b) what is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, cache block, and block offset fields (if they apply)? (c) to which cache block will the memory reference db6316 map?
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
This graph compares the total cost of attending educational institutions in texas. the graph demonstrates that the cost at private and public technical schools greatly varies.
Answers: 2
question
Computers and Technology, 23.06.2019 18:30
Janice recently received her college degree and is looking for a job. she is worried that since she just finished school, she will be required to repay her perkins and direct subsidized loans immediately. janice pulls out the paperwork she signed and reviews it again for repayment information. after reading all of the information, janice discovers that
Answers: 2
question
Computers and Technology, 25.06.2019 05:30
The piston ring isn't a completely solid ring; instead, it's usually split at one point. this split or gap in the ring is called the a. ring spacing. b. ring clearance. c. ring end gap. d. ring side clearance.
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
Questions on the website: 13722360