Question: def cal _ area ( base , height, mode = rectangle ) : # Check if the base or height is negative if base <

def cal_area(base, height, mode="rectangle"): # Check if the base or height is negative if base <0 or height <0: return "Base and height must be non-negative values." # Check the mode and calculate the area accordingly if mode == "rectangle": area = base * height return f"The area of the rectangle is: {area}" elif mode == "triangle": area =0.5* base * height return f"The area of the triangle is: {area}" else: return "Invalid mode. Please use 'rectangle' or 'triangle'."

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!