Answer to Question #274942 in Python for kika

Question #274942

2. Write your own unique Python program that has a runtime error


1
Expert's answer
2021-12-04T12:13:14-0500
# Python 3.9.5

# First case runtime error,
# if you are trying to use a variable in an inappropriate format

age_your_father = input('How old your father: ')
if age_your_father > 50:                        # Here we have TypeError,
    print('Your father very old')               # because we try to compare
                                                # the string with the number

# Second type, if you trying to refer to an item in the list that does not exist

list = ['1', '2', '3']
print(list[3])                                  # Here we have IndexError,
                                                # because we trying get element
                                                # by index, that does not exist

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS