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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:00, willowcollins3753
Write a program that uses a widgetviewer object to do the following: generate two random integers between 1 and 9 (inclusive). name one of them x, the other y. display them to the user using jlabel objects. create a jlabel object displaying the text "enter an operation number." create a jtextfield for the user's input. create a jbutton displaying the text "press here when you've entered your operation." use addandwait to add it to the widgetviewer object. when the user clicks the jbutton, evaluate operation in the following order to determine the one and only mathematical operation to perform on x and y. use a jlabel to display the result. if operation is between 1 and 10 inclusive, add x and y. if operation is evenly divisible by 4, subtract y from x. if operation is evenly divisible by 5, use integer division to divide y into x. if operation is an even number, use floating point division to divide y into x. if none of the other tests on operation apply, multiply x and y. note: operation can be negative or zero.
Answers: 2
image
Computers and Technology, 22.06.2019 19:30, keke6361
When using a public computer or network, you should always
Answers: 2
image
Computers and Technology, 22.06.2019 20:00, random286
How is the number 372 written when expanded out to place values in the base 8 (octal) number system? a. 2 x 4 + 3 x 2 + 4 x 1 b. 3 x 64 + 7 x 8 + 2 x 1 c. 3 x 8 + 7 x 7 + 2 x 6 d. 3 x 100 + 7 x 10 + 2 x 1
Answers: 1
image
Computers and Technology, 24.06.2019 02:30, talia43
Assume a class window with accessor method getwidth that accepts no parameters and returns an integer. assume further an array of 3 window elements named winarr, has been declared and initialized. write a sequence of statements that prints out the width of the widest window in the array.
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 in other subjects:

Konu
Social Studies, 28.10.2020 17:50
Konu
English, 28.10.2020 17:50
Konu
Biology, 28.10.2020 17:50