Westonci.ca is your trusted source for accurate answers to all your questions. Join our community and start learning today! Join our Q&A platform and connect with professionals ready to provide precise answers to your questions in various areas. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.

You wrote a program to allow the user to guess a number. Complete the code to get a number from the user.

# Get a guess from the user and update the number of guesses.

guess =

("Guess an integer from 1 to 10: ")

NEED HELP FAST


Sagot :

Answer:

import random

number = random.randrange(1, 10)

is_guess = 'y'

while is_guess == 'y':

   try:

       guess = int(input("Guess an integer number between 1 and 10: "))

       if guess < 1 or guess >10:

           print("You have exceeded the guessing range, try again")

           continue

       elif guess == number:

           print("Congrats! You guessed right.")

       else:

           print("Sorry, you guessed wrong")

   except ValueError:

       print("Your guess must be an integer number.")

   is_guess = input("Do you want to try again y/n ? ")

Explanation:

The random module of the python programming language is used to randomly select an integer value from a range of numbers. The guess variable value is a user input of an integer number.

If the guess variable is equal to the random number, then the program prints a congratulatory message. The program is no constant loop so long as the is_guess variable is equal to 'y'.

The try-except statement is used to detect the value error of the guess variable.

Answer:

input

Explanation:

We appreciate your time. Please revisit us for more reliable answers to any questions you may have. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. We're dedicated to helping you find the answers you need at Westonci.ca. Don't hesitate to return for more.