A developer has been receiving unexpected error messages on the 3rd function call when running their python program. Loo

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

A developer has been receiving unexpected error messages on the 3rd function call when running their python program. Loo

Post by answerhappygod »

A developer has been receiving unexpected error messages on the3rd function call when running their python program. Looking at thecode below, what might be the issue?
A Developer Has Been Receiving Unexpected Error Messages On The 3rd Function Call When Running Their Python Program Loo 1
A Developer Has Been Receiving Unexpected Error Messages On The 3rd Function Call When Running Their Python Program Loo 1 (11.45 KiB) Viewed 25 times
a)
There is no 'return area' statement
b)
The if conditional is not within the try/catch block
c)
The function needs to cast str inputs to int
d)
The developer is lacking sleep and needs more coffee to spot atypo
#area of a rectangle formula def findrectanglearea(base, if base <= 0 or height <= 0: height): print("Please provide only positive values") # try/catch block to perform input validation try: base = float (base) height = float (height) area = base * height print("Please provide a valid input") except: # Test the function to find the area of a rectangle findrectanglearea (3,10) findrectanglearea (-17,4) findrectanglearea('foo', 'bar')
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply