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 07:00
Robots with telescoping arms are sometimes used to perform tasks (e.g., welding or placing screws) where access may be difficult for other robotic types. during a test run, a robot arm is programmed to extend according to the relationship r = 3 + 0.5cos(4θ) and the arm rotates according to the relationship θ=−π4t2+πt , where r is in feet, θ is in radians, and t is in seconds. use a computer program to plot the path of tip a in x and y coordinates for 0 ≤ t ≤ 4s.
Answers: 2
question
Computers and Technology, 23.06.2019 00:20
Ihave been given the number of guns per 100, and the total firearm-related deaths per 100,000. i have to find the actual number of guns per country and actual number of gun-related deaths. if somebody could show me how to do 1 question, i can finish the rest, i am just confused. tia
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 23.06.2019 06:40
What are the three uses of a screw?
Answers: 2
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
Health, 25.04.2020 22:29
question
Mathematics, 25.04.2020 22:29
question
Mathematics, 25.04.2020 22:29
question
Physics, 25.04.2020 22:29
Questions on the website: 13722362