aa
This commit is contained in:
23
example.py
Normal file
23
example.py
Normal file
@@ -0,0 +1,23 @@
|
||||
def calculate_area(length, width):
|
||||
"""
|
||||
Calculate the area of a rectangle.
|
||||
|
||||
Args:
|
||||
length (float): The length of the rectangle
|
||||
width (float): The width of the rectangle
|
||||
|
||||
Returns:
|
||||
float: The area of the rectangle
|
||||
"""
|
||||
if length <= 0 or width <= 0:
|
||||
raise ValueError("Length and width must be positive numbers")
|
||||
|
||||
return length * width
|
||||
|
||||
# Example usage
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
area = calculate_area(5, 3)
|
||||
print(f"The area is: {area}")
|
||||
except ValueError as e:
|
||||
print(f"Error: {e}")
|
||||
Reference in New Issue
Block a user