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
"a​ _______ network delivers user data in many different geographical locations and makes those data available in a way that min
alina1380 [7]
A satellite network.

6 0
4 years ago
ILL GIVE BRAINLIEST TO FIRST ANSWER David is adopting an iOS app from a non-retina screen to a retina screen. The app currently
Aleksandr [31]

Answer: what density should it be on a retina screen to maintain its apparent size?

7 0
3 years ago
In an email, above subject, what does cc mean?
IRISSAK [1]
It stands for carbon copy.
7 0
3 years ago
What chage command should you enter at the comman prompt to set the password to jsmith expire after 60 days and gives a warning
Nat2105 [25]

Answer:

chage -M 60 -W 10 jsmith

Explanation:

The command chage -M 60 -W 10 jsmith is used to set the password to jsmith so that it will expires after 60 days and this command will also gives the warning 10 days prior to the expiration of the password.This command is for command prompt.We can also change the expiration and warning by changing the integers in the command respectively.

3 0
4 years ago
Create a new method in your language called Times Print. This should be a void method. It should accept exactly two numeric valu
user100 [1]

Answer:

The code commented is given below, also the lines that start with # are comments that explains the code.

# Create a function named times_print that receives 2 values x and y

def times_print(x, y):

   # Print the formatted string

   print("The value of {} times {} is {}".format(x,y,x*y))

# Create the main function

def main():

   # Call the funciton times_print 3 times with different values

   times_print(2,3)

   times_print(4,5)

   times_print(5,6)

# Execute the main function

main()

Explanation:

The code was written using Python 3.5, and here I attach the screenshots of the program running:

8 0
4 years ago
Other questions:
  • Which of the following has the responsibility of offering instruction on intrusion detection systems and intrusion prevention sy
    11·1 answer
  • Which career professional and creates large data base and makes the data base with other systems
    13·1 answer
  • Please help!
    10·2 answers
  • Discuss how does a Modulus Operator function
    7·1 answer
  • Anyone know the answer I need help
    12·1 answer
  • Anyone tell my answer.
    15·1 answer
  • Discuss why it is important to know the history of social media​
    10·1 answer
  • Games set in modern times are less difficult to a tie to a specific culture than games set in past eras
    14·1 answer
  • Pls help
    13·1 answer
  • True or false. A plug-in card is always required to support pc sound
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!