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
Can a idler gear increase or decrease torque?
Lady bird [3.3K]

answer:The gear is called an idler and its primary function is to change the direction of rotation rather than decrease the speed or increase the torque. Calculating the gear ratio in a planetary gear reducer is less intuitive as it is dependent on the number of teeth of the sun and ring gears.

Explanation:

8 0
3 years ago
We have three containers whose sizes are 10 pints, 7 pints, and 4 pints, respectively. The 7-pint and 4-pint containers start ou
kobusy [5.1K]

Answer:

Yes, there is a sequence, and at the end of the sequence the following arrangement will be in each container;

10-pint container will contain 2 pints of water

7-pint container will contain 7 pints of water

4-pint container will contain 2 pints of water

Explanation:

The 7- and 4-pint containers are full, while the 10-pint container is initially full.

The following steps are followed;

1. pour the content of the 7-pint container into the 10-pint container, and pour 3-pint of water from the 4-pint container to fill up the 10-pint container, leaving the following in the three containers

10-pint container will contain 10 pints of water

7-pint container will contain 0 pints of water

4-pint container will contain 1 pints of water

2. Next, pour the 1 pint of water from the 4-pint container into the 7-pint container, and in turn pour from the 10-pint container into the 4-pint container until it is full, leaving the following in the three containers;

10-pint container will contain 6 pints of water

7-pint container will contain 1 pints of water

4-pint container will contain 4 pints of water

3. next, pour all the content of the 4-pint container into the 7-pint container, and refill the 4-pint container by pouring into it from the 10-pint container, leaving the following in the 3 containers;

10-pint container will contain 2 pints of water

7-pint container will contain 5 pints of water

4-pint container will contain 4 pints of water

4, Finally, pour from the 4-pint container into the 7-pint container until it is full, leaving the following in the 3 containers;

10-pint container will contain 2 pints of water

7-pint container will contain 7 pints of water

4-pint container will contain 2 pints of water.

There you go, this sequence leaves 2-pint of water in the 4-pint container.

4 0
3 years ago
Read 2 more answers
Which of the following is a productivity strategy for collaboration?
AfilCa [17]

Answer:

Where are the answer choices? Can you put them down so I can answer them?

Explanation:

8 0
3 years ago
Which phrase is a comparison operator for inserting a not equal to argument in an IF, COUNTIF or SUMIF function? &lt;= &lt;&gt;
natta225 [31]

Answer:<>

Explanation: <> is the comparison operator which helps in evaluating if the values are not equal to each other.

4 0
4 years ago
Which Internet connection type tends to use shared bandwidth?<br> Cable<br> Dial-up<br> DSL<br> ISDN
zmey [24]

Answer:

try dial-up

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • Why is there a need to compare and align one's PECs of a successful entrepreneur?
    5·1 answer
  • Terminal resource security is a software feature that erases the screen and signs a user off automatically after a specified len
    14·1 answer
  • Why did Simon bring Michael home?​
    9·2 answers
  • The methods in a subclass can use all of the data fields and methods that belong to its parent, with one exception: ____ members
    11·1 answer
  • Translate each statement into a logical expression. Then negate the expression by adding a negation operation to the beginning o
    15·1 answer
  • Please help with coding assignment.
    11·1 answer
  • I'm getting pretty desperate plz help me, I'll give brainiest, and ill make a free question worth 100 points this is for coding
    8·2 answers
  • When would the Jerusalem virus attack?<br> 1. Friday the 13th<br> 2. Wednesday the 13th
    13·2 answers
  • assume there are K sorted lists, each of n/k elements. We want to merge them into a single sorted list of n elements. Give an op
    7·1 answer
  • What is one of four key principles of Responsible Artificial Intelligence
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!