Calculates the area of a parallelogram given the coordinates (x,y,z) of three points.
import numpy as np def get_vector(name): while True: raw = input("Enter vector " + name + " as three \n comma-separated numbers \n(e.g., 1, 2, 3): ") try: parts = [float(x.strip()) for x in raw.split(",")] if len(parts) != 3: print("Please enter exactly three values.") continue return parts except ValueError: print("Invalid input. Make sure all entries are numbers.") print("Before we begin, remember:\n q must lie between p and r \n along the same line.\n") p = get_vector("p") q = get_vector("q") r = get_vector("r") def a(p, q, r): PQ = np.array(q) - np.array(p) PR = np.array(r) - np.array(p) cross_product = np.cross(PQ, PR) area = np.sqrt(np.sum(cross_product**2)) return area area = a(p, q, r) print("\nThe area of the parallelogram \n formed by PQ and PR is: \n" + str(round(area,3)))