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
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)
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')
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')