fbpx

GuessMyNumber_Week5

Guess the Number Week 5
You will add to the program you created in Week 4. This week you will add input validation and a count to show how many guesses the user took before getting the correct number. Be sure to import random at the beginning of your code and use a comment block explaining what your program does.
Pseudocode:
#Guess the number week 5
#Name:
#Date:
#Random number, loop while true
#ask user for number. Check to see if the value is a number between 1 and 10
#if number is too high or too low, tell user, if they guessed it break out of loop
Display “Welcome to my Guess the number program!”
random mynumber
count=1
while True
try
Display “Guess a number between 1 and 10”
Get guess
while guess<1 or guess>10
Display “Guess a number between 1 and 10”
Get guess
except
Display “numbers only”
continue
if (guessmynumber)
Display “Too high”
count=count+1
else if (guess==mynumber)
Display “You guessed it in “+ count + ” attempts”

Expected Result of Program:

×
New Download