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!”)

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter8: Arrays
Section: Chapter Questions
Problem 10RQ
icon
Related questions
Question
100%

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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning