Page 1 of 1

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

Posted: Fri Jul 01, 2022 5:42 am
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 27 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')