subject

Python question: write a program that generates a random number in the range of 1 through 100, and asks the user to guess what the number is. if the user’s guess is higher that the random number the program should display "too high try again." if the user’s guess is lower than the random number, the program should display "too low, try again" if the user guesses the number the application should congratulate the user and then generate a new random number so the game can start over.

this is what i have so far..

#generates and imports a random number between 1-100
import random
number=random. randint(1,100)

#sets main function
def main():
print("this is a number guessing game.")
print("guess what number we thought of between 1 and 100")
#print statement

num = number()
#stores number of user guesses
user = 0
#stores number of guesses
guesses = 0
#while statement
while user ! = num:

user=int(input("enter your best guess! "))

guesses=guesses +1

if (user > num):
print ("too high, try again")
else:
print("congrats, you won! ")
print("restarting game")

main()

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:50, brennarfa
17. implement the jvm dload instruction for the mic-2. it has a 1-byte index and pushes the local variable at this position onto the stack. then it pushes the next higher word onto the stack as well
Answers: 2
image
Computers and Technology, 22.06.2019 21:30, mjweed2456
Nathan wants to create multiple worksheet containing common formatting styles for his team members. which file extension him to save these worksheets? nathan to create multiple worksheets with common styles. he needs to save them with the extension.
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, rscvsdfsrysas3712
Why is an outfitting a workspace with video games in a technology development company considered a strategic use of money
Answers: 1
image
Computers and Technology, 23.06.2019 19:00, jacobbecker99
Choose the correct citation for the case which established the "minimum contacts" test for a court's jurisdiction in a case. select one: a. brown v. board of education of topeka, 347 u. s. 483 (1954). b. international shoe co. v. washington, 326 u. s. 310 (1945) c. haynes v. gore, 531 u. s. 98 (2000). d. international shoe co. v. washington, 14 u. s. code 336.
Answers: 1
You know the right answer?
Python question: write a program that generates a random number in the range of 1 through 100, and...

Questions in other subjects:

Konu
Mathematics, 06.04.2020 01:54
Konu
Mathematics, 06.04.2020 01:54