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.
![Porter_GuessNumber.py - C:/Users/shawn/OneDrive/Desktop/CIS123/Porter_GuessNumber.p...
File Edit Format Run Options Window Help
from random import randint
print ("micpor9577")
num = randint (1,9)
user_guess = 0
while user_guess != num:
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")
print("You guessed it!")
else:
X
Ln: 12 Col: 28](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F4d27a8a6-cc74-416c-a782-397e5cce3206%2Fba74a92f-5973-4c74-b4cd-e366b74b5071%2F505e7wn_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 5 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)