''' distance_two_points.py
calculate the distance between two points given the coordinates
of the points (x1, y1) and (x2, y2) in a 2D system
'''
import math
def get_distance(x1, y1, x2, y2):
'''
returns distance between two points using the pythagorean theorem
the function parameters are the 2D coordinates of the two points
'''
dx = x2 - x1
dy = y2 - y1
return math.sqrt(dx**2 + dy**2)
sf = "Distance between point({}, {}) and point({}, {}) is {}"
x1, y1 = 1, 3
x2, y2 = 4, 7
print(sf.format(x1, y1, x2, y2, get_distance(x1, y1, x2, y2)))
x1, y1 = 2, 5
x2, y2 = 11, 23
print(sf.format(x1, y1, x2, y2, get_distance(x1, y1, x2, y2)))
''' result ...
Distance between point(1, 3) and point(4, 7) is 5.0
Distance between point(2, 5) and point(11, 23) is 20.1246117975
'''

Hello people. I'm looking for FP examples that are very simple (very few lines, one-liners are even better) and that totally look like sorcery to a traditional imperative programmer. Can ...

This might be a simple problem but I had difficulties finding a solution. I'm trying to return data in specified formats for the same input. I've data in two tables ...