Please make a Python program where the computer chooses a number and the player guesses the number. And at the end, please report the number of attempts.
You need an input, a random number, if statement, and a while loop. Please reference the pre-lab document in the Blackboard.
Please prepare a Word document that has the Python code and the screen shot of your output.
Here is a sample of what the output screen should look like.
What is your guess? 97
Too high
What is your guess? 6
Too low
What is your guess? 38
Correct!
>>>
PROGRAM SCREENSHOT:
Sample output:
Code to copy:
# import the required module for random integers
from random import randint
# number by CPU system
computer = randint(1,100)
# initialize the guess
guess = 0
# iterate loop
while True:
# take user input
num = int(input("What is your guess? "))
# check if user input is greater than computer guess
if num > computer:
# print output
print("Too High")
# check if user input is less than computer guess
elif num < computer:
# print output
print("Too Low")
# otherwise
else:
# print correct guess
print("Correct")
# break the loop after correct guess
break;
# increment the guess
guess = guess + 1
---------------------------------------------------------------------------------
#################################################
##### PLEASE UPVOTE ####
#################################################
Get Answers For Free
Most questions answered within 1 hours.