""" Ex 6.9 from A Primer on... We already have a function for computing the area for a list of coordinates. The only change needed is that we must look up in a dictionary with keys 1,2,3 rather than a list with indices 0,1,2. """ def triangle_area(v): x1, y1 = v[1]; x2, y2 = v[2]; x3,y3 = v[3] return 0.5*abs(x2*y3-x3*y2-x1*y3+x3*y1+x1*y2-x2*y1) corners = {1:(0,0),2:(1,0),3:(0,2)} answer = f"""The area of a triangle with corners {corners[1]}, {corners[2]}, and {corners[3]} is {triangle_area(corners)}.""" print(answer) """ Terminal> python area_triangle_dict.py The area of a triangle with corners (0, 0), (1, 0), and (0, 2) is 1.0. """