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

Another question on Computers and Technology

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 08:30
Helen's credit card has an apr of 15.32% and a grace period of 17 days and helen pays her balance in the full every month. if her last billing cycle ended on september 26, 2009, and she made her payment on october 11, 2009, did she owe any interest on her last statement's balance?
Answers: 3
question
Computers and Technology, 23.06.2019 09:00
Which best describes the role or restriction enzymes in the analysis of edna a. to break dna into fragments that vary in size so they can be sorted and analyzed b. to amplify small amounts of dna and generate large amounts of dna for analysis c. to purify samples of dna obtained from the environment so they can be analyzed d. to sort different sizes of dna fragments into a banding pattern that can be analyzed
Answers: 1
question
Computers and Technology, 24.06.2019 02:40
Has anyone seen my grandma shes been gone for 4 years already
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
question
Mathematics, 15.01.2021 16:20
question
Physics, 15.01.2021 16:20
question
Mathematics, 15.01.2021 16:20
Questions on the website: 13722367