CPSC120A
Fundamentals of Computer Science I

Post-lab 11

Fruitful Functions

Do one of the following programming problems:

Distance

Write a Python function distance(x1, y1, x2, y2) that returns the distance between the specified two-dimensional points, (x1, y1) and (x2, y2). The distance, \(d\), between two points can be calculated with the equation:

$$d = \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}$$


Trapezoid Area

Write a Python function trapezoid_area(base_length, top_length, height) that returns the area of the specified trapezoid.