# This program demonstrates how to define and call a function in Python, including passing arguments and returning a value.
def calculate_rectangle_area(width, height): # Defines a function named 'calculate_rectangle_area' that accepts two parameters.
area = width * height # Multiplies width by height and stores the result in 'area'.
return area # Sends the calculated area value back to the caller.
# Main program execution starts here
room_width = 12 # Assigns the integer value 12 to 'room_width'.
room_height = 15 # Assigns the integer value 15 to 'room_height'.
# Calls the function and stores the returned result in 'total_area'.
total_area = calculate_rectangle_area(room_width, room_height)
print("The area of the room is:", total_area) # Prints the final message and result to the console.
Comments
Post a Comment