Answer to Question #237961 in Python for Joel

Question #237961

. Write your own unique Python program that has a runtime error. Do not copy the program from your textbook or the Internet. Provide the following.

  • The code of your program.
  • Output demonstrating the runtime error, including the error message.
  • An explanation of the error message.
  • An explanation of how to fix the error.
1
Expert's answer
2021-09-18T23:56:57-0400
#demonstrating run time error
N=input("Enter first name: ")
S=input("Enter the second name: ")
print(N-S)

Error message

 print(N-S)

TypeError: unsupported operand type(s) for -: 'str' and 'str'

Run time error here occurs when you try to subtract a string with another string.

The error can be fixed by changing the inputs to intergers.

#Fixing the run time error
N=int(input("Enter first interger: "))
S=int(input("Enter the second interger: "))
print(N-S)

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