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
natulia [17]
3 years ago
11

# line 1 age = int(input("Enter your age: ")) # line 3 print("Invalid input") If we want the computer to display "Invalid input"

whenever a floating point number such as 20.5 is entered by the user, what should be inserted in line 1 and line 3?

Engineering
1 answer:
user100 [1]3 years ago
5 0

Answer:

Insert

'try:' at line 1

'except:' at line 3

Explanation:

The "try and except" commands in Python are used for exception handling.

try: the statements under this block are executed normally

except: the the statements under this block are executed when there is an exception.

We can use these commands to handle errors, for example, in the given scenario we don't want the user to enter a floating point number such as

1.5, 2.6 etc.

When the user enters an integer number then the except command is not executed.

When the user enters a floating point number then the except command is executed, program is stopped and error message is shown that is at line 4

Python code:  

# line 1

try:

# line 2

   age = int(input("Enter your age: "))

# line 3

except:

# line 4

   print("Invalid input")

Output:

Test 1:

Enter your age: 20

Test 2:

Enter your age: 20.5

Invalid input

You might be interested in
# derive is a kind of which dependency
Gemiola [76]
Types of dependency relationships
Type of dependency Keyword or Stereotype
Abstraction «abstraction», «derive», «refine», or «trace»
Binding «bind»
Realization «realize»
Substitution «substitute
6 0
3 years ago
With a brief description, What are the 14 principles of management by fayol.​
Rudik [331]

Answer:

is all about focus and unity.

Explanation:

All employees deliver the same activities that can be linked to the same objectives.

7 0
4 years ago
What ratio between differential gain and common-mode gain is called​
dlinn [17]

Answer:

CMRR(Common Mode Rejection Ratio) is the ratio of differential gain and the common mode gain.

Explanation:

8 0
3 years ago
Are all transmissions fluids interchangeable
KiRa [710]

Answer:

<u>No</u>.

Explanation:

They are not all the same. Moreover, using a fluid that is not approved by the vehicle manufacturer will void the transmission warranty.

6 0
3 years ago
Why are communication (verbal, written and drawing) skills so important to have as an engineer?
amm1812

Answer:

Both written and verbal communication skills are of the utmost importance in business, especially in engineering. Communication skills boost you or your teams' performance because they provide clear information and expectations to help manage and deliver excellent work.

3 0
3 years ago
Other questions:
  • Consider a Pitot static tube mounted on the nose of an experimental airplane. A Pitot tube measures the total pressure at the ti
    12·1 answer
  • The raw plastic that will be molded into a brick shape actually
    9·1 answer
  • explain the four functional blocks on an oscilloscope and describe the major controls within each block
    6·1 answer
  • 1.00-L insulated bottle is full of tea at 90.08°C. You pour out one cup of tea and immediately screw the stopper back on the bot
    6·1 answer
  • Has anyone lost faith in humanity ✌️
    7·1 answer
  • Need help hurry 20 Briefly describe an idea for a new product, while thinking mainly about its cost analysis. Depict what kinds
    14·1 answer
  • I'll give a free brainliest
    7·2 answers
  • 1. Safety goggles, glasses, or face shields must be
    6·2 answers
  • Which of the following types of piles would be most appropriate for anchoring a building in bedrock?
    5·1 answer
  • Equipment that is not properly stored can create trip and fall hazards in the work area.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!