Loading [MathJax]/jax/output/HTML-CSS/jax.js

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=(x1x2)2+(y1y2)2


Trapezoid Area

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