1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
andrey2020 [161]
4 years ago
11

Using a WHILE loop write a program that asks the user to guess your favorite number. The program should end when the user guesse

s correctly, but otherwise provides hints for guessing higher or lower. Use the Try/Except/Else structure to ensure that the user enters numbers. Name this program guessNumber.py
Computers and Technology
1 answer:
eduard4 years ago
4 0

Answer:

fav_number=26

guess=0

while 0==0:

   try:

       guess=int(input('Enter your guess: '))

   except:

       print ('You have entered an invalid value.')

   else:

       if guess == fav_number:

           break

       elif guess>fav_number:

            print ('Try a smaller number.')

       elif guess<fav_number:

           print ('Try a larger number')

Explanation:

define a variable fav_number and set it to number. write an infinite while loop to read input from user. In try block get input from user, if user enters invalid input code in except block will be executed. For valid input

  1. check if its greater than favorite number, if yes print try smaller number.
  2. check if its smaller than favorite number, if yes print try larger number.
  3. check if its equal to favorite number, break loop and exit

You might be interested in
Public static void prefixmerge(customer[] list1, customer[] list2, customer[] result {
White raven [17]
I can't get what do you need, but I guess it's a part of java code. I can explain what it means. It's used to unite two rising sorted arrays which are list1 and list2. The result is stored in result array. I suggest you to clearly explain your task as it's difficult to give you correct answer.
8 0
4 years ago
Microsoft Windows is the least used operating system. TRUE or FALSE.
Katen [24]
<span>This is false. In the context of the US, Microsoft Windows is the operating system used the most. In fact, 1.5 billion people worldwide use Microsoft Windows. </span>
4 0
3 years ago
Why do you think fax machines use RLE?
Mashutka [201]

Answer:

Fax machines still use RLE for compressing the faxed documents, since they only need to represent black and white letters. JPEG images do use RLE during a final stage of compression, but they first use a more complex algorithm to compress the photographic details

8 0
3 years ago
What does “modulate your voice” mean?
Pachacha [2.7K]
A) when u modulate some thing you vary it
5 0
3 years ago
In Excel you insert a comment in a worksheet by using the ____ tab on the Ribbon.
White raven [17]
Review
(I was suprised too)
3 0
4 years ago
Other questions:
  • Write a program that takes nouns and forms their plurals on the basis of these rules:
    8·1 answer
  • What observational data required the revision of the early geocentric model?
    5·1 answer
  • What is an icon or animation used to represent a participant in an internet chat referred to as
    15·2 answers
  • I cannot figure out how to cancel my Brainly subscription. I can’t click “account settings” and “cancel subscription” cuz when I
    5·2 answers
  • What Is The Oldest Known Analog Computer In The World?
    14·1 answer
  • 5. What must be included in Turtle Graphics to move the Turtle around the screen?
    7·1 answer
  • Consider the following code: x = 9 y = -2 z = 2 print (x + y * z) What is output? 9 13 14 5
    5·1 answer
  • When you send large attachments, you are not
    14·1 answer
  • Select all the correct answers.
    8·1 answer
  • True or false: Quality score is an algorithm that scores each of your search ads on spelling and grammar.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!