The D.R.Y. Principle Visualizer

The Copy-Paste Nightmare
# Site A
d1 = ((x2-x1)*2 + (y2-y1)*2)**0.5
# Site B
d2 = ((x2-x1)*2 + (y2-y1)*2)**0.5
# Site C
d3 = ((x2-x1)*2 + (y2-y1)*2)**0.5
The Function Approach
def calc_dist(x1, y1, x2, y2):
    return ((x2-x1)*2 + (y2-y1)*2)**0.5
d1 = calc_dist(site_A)
d2 = calc_dist(site_B)
d3 = calc_dist(site_C)
Both scripts calculate the distance for 3 different sites. The left uses copy-paste, the right uses a reusable function.