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
A simply supported wood roof beam is loaded with single point dead and roof live loads applied at midspan (PD = 400 lb, PLr = 16
Lynna [10]

Answer:mold i belive

Explanation:

3 0
3 years ago
Compute the solution to x + 2x + 2x = 0 for Xo = 0 mm, vo = 1 mm/s and write down the closed-form expression for the response.
Nutka1998 [239]

Answer:

β = \frac{c}{\sqrt{km} } =  0.7071 ≈ 1 ( damping condition )

closed-form expression for the response is attached below

Explanation:

Given :  x + 2x + 2x = 0   for Xo = 0 mm and Vo = 1 mm/s

computing a solution :

M = 1,

c = 2,

k = 2,

Wn = \sqrt{\frac{k}{m} }  = \sqrt{2}  

next we determine the damping condition using the damping formula

β = \frac{c}{\sqrt{km} } =  0.7071 ≈ 1

from the condition above it can be said that the damping condition indicates underdamping

attached below is the closed form expression for the response

6 0
3 years ago
You are investigating surface hardening in iron using nitrogen gas. Two 5 mm thick slabs of iron are separately exposed to nitro
Luden [163]

Answer and Explanation:

The explanation is attached below

4 0
3 years ago
A gas metal arc welder is also known as a _____ welder.<br> A) TIGB) GTAWC) GMAWD) Resistance spot
nignag [31]

Answer:

GMAW

Explanation:

It's literally the initials of that type of welding

7 0
3 years ago
Write an<br> algorithm and draw a flowchart to convert the length in feet to<br> centimeter
Simora [160]

Answer:

blah blah blah sh ut up read learn

3 0
3 years ago
Other questions:
  • The fouling on the heat exchanger surfaces causes additional thermal resistance, thus decreases the heat transfer rate. a)- True
    11·1 answer
  • The component of a fluid system where a fluid is stored, but not under pressure, is called a container.
    5·1 answer
  • Determine the average and rms values for the function, y(t)=25+10sino it over the time periods (a) 0 to 0.1 sec and (b) 0 to 1/3
    9·1 answer
  • When will the entropy value of the universe attained its maximum value?
    13·1 answer
  • Explain what a margin of safety is in driving as well as how it can help minimize risk.
    14·1 answer
  • The guy wires AB and AC are attached to the top of the transmission tower. The tension in cable AB is 8.7 kN. Determine the requ
    8·1 answer
  • Please help on two I will give brainiest​
    13·2 answers
  • Raw materials used of silicone rubber
    6·2 answers
  • Is there a project idea, or invention that would be good for<br> my class.
    6·2 answers
  • A ___ is a type of purlin used as a horizontal stiffener between columns around the perimeter of a building.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!