Have the computer select a random number with the following commands: from random import randint print(“”) num = randint(1,9) user_guess = 0 Create a loop that will check to see if the user_guess is the same as the random number while user_guess != num: Inside the loop get a guess from the user and check to see if the guess is lower than the number user_guess = int(input(“Enter a guess from 1 to 9: “)) if user_guess < num: print(“Guess is low”) elif user_guess > num: print(“Guess is high”) else: print(“You guessed it!”)
This is python. I attached my current code as a picture. My "Guess is low" and "Guess is high" wont work. But if I guess the correct number it works. Here are the instructions.
Open the Python 3.10 Integrated Development Learning Environment (IDLE) and create a new project
named, GuessNumber
Have the computer select a random number with the following commands:
from random import randint
print(“<Your Student number>”)
num = randint(1,9)
user_guess = 0
Create a loop that will check to see if the user_guess is the same as the random number
while user_guess != num:
Inside the loop get a guess from the user and check to see if the guess is lower than the number
user_guess = int(input(“Enter a guess from 1 to 9: “))
if user_guess < num:
print(“Guess is low”)
elif user_guess > num:
print(“Guess is high”)
else:
print(“You guessed it!”)
Keep running the program until you get one Guess is high, Guess is low, and you guessed it response.


Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 5 images









