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

Answers

Answer 1

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 2

Answer:

input

Explanation:


Related Questions

Other Questions
What terms in the question need to be defined How did life change in the Americas after the arrival of Europeans?please I need a 3 paragraph essay about this topic thank you As of January 2009, the USA has produced 60,000 metric tons of nuclear waste in 60 yesrs of operating 104 nuclear power plants.on average how much waste is produced by each plant on a monthly basis?a. 0.8 tons p. monthb. 83.3 tons p. monthc. 104 tons p. monthd. 866.3 tons p. month what is the y intercept how has the creation of job specialization impacted society today? I need help with Geometry What is instrumental helping? A triangle has side lengths of 19 centimetres, 19 centimetres, and 20 centimetres. Is this triangle equilateral? How does GDP accounting record the following events? For each of them, describe how they would be computed in GDP accounts using the income method, the production method, and the expenditure method.a. Tom purchases a brand new Volkswagen from Germany for his start up ride sharing business for $20,000. He provides ride-sharing services earning him revenues of $40,000. During the course of the year, the Volkswagen depreciates by $2,000. Tom has no other costs.b. An army battalion is deployed to the border to repel a threatened Canadian invasion. The soldiers earn wages of $10,000 and use ammunition that the government bought for $5,000. The ammunition was produced using $2,000 of imported steel and 100 hours of work, for which the workers were paid $1,000. Hint: two things are produced in this example, what is the value added for each of them?c. The government collects $1000 in income taxes from Pam.d. Pam earns $4000 for working as a babysitter and pays $1000 in income taxes. Trends that have contributed to the recent increase in eating disorders in the United States include a(n): a. More competitive workplace b. Increase in the number of divorces c. Focus on being thin as a measure of attractiveness d. Increase in the number of nonnutritional foods consumed ANS: C In most modern societies, a high value is placed on a slim body. who whose the first president of Somaliland in the albas's study of impression management, in which type of interaction did students often explain that they were not feeling well as a way of saving face Write an explicit formula of an , the nth term of the sequence 22,20,18 Jorge is talentedin English, Spanish, and French. Bren has a deck of cards. As shown below, each card is labeled with a rule describing a pattern in a sequence.select a card and decide on a starting number. Use the rule to write the first five terms in your sequence. Add 1.6 Add 0.33 add 6.5 Add 0.25 Add 1.15 what are some similarities between the aztec and ottoman empires? What are the advantages and disadvantages of medicine? Which of the following is NOT an argument for showing that the Earth must be round: a. during an eclipse of the Moon, the shadow of the Earth is always seen to be round b. when ships travel a large distance away, we see their hulls disappear first and their masts disappear last c. the height of the North Star changes as we travel to different latitudes d. photographs of the Earth from space always show a round body e. the Sun is seen blocking different constellations in the course of a year Submit Your Answer Plz help me I need tu turn this is by midnight!! how does the fog make 'men of boys,And giants of tall men'?From the poem The fog by William Henry Davies