Construct a function 'coordinates', that will return the distance between two points on a cartesian plane, given the x and y coordinates of each point.

There are two parameters in the function, ```p1``` and ```p2```. ```p1``` is a list ```[x1,y1]``` where ```x1``` and ```y1``` are the x and y coordinates of the first point. ```p2``` is a list ```[x2,y2]``` where ```x2``` and ```y2``` are the x and y coordinates of the second point. 

The distance between the two points should be rounded to the `precision` decimal if provided, otherwise to the nearest integer.

Difficulty: introductory

Starter code:

def coordinates(p1, p2, precision=0):
	

Solutions:
def coordinates(p1,p2, precision = 0):
    return round(sum( (b-a)**2 for a,b in zip(p1,p2) )**.5, precision)

import math

def coordinates(p1, p2, precision=0):
    return round(math.hypot(p1[0] - p2[0], p1[1] - p2[1]), precision)

def coordinates(a, b, p = 0):
    return round(sum((i - j) ** 2 for i, j in zip(a, b)) ** 0.5, p)

from math import hypot

def coordinates(p1, p2, r=0):
    x1, y1 = p1
    x2, y2 = p2
    return round(hypot(x2 - x1, y2 - y1), r)
    
# one-liner:
#   return round(sum((c2 - c1)**2 for c1, c2 in zip(p1, p2))**0.5, r)


import math

def coordinates(p1,p2,p=0):
    return round(math.hypot(abs(p1[0]-p2[0]), abs(p1[1] - p2[1])), p)

from math import hypot

def coordinates(p1, p2, precision=0):
    return round(hypot(p1[0] - p2[0], p1[1] - p2[1]), precision)

import math
def coordinates(p1,p2, d=0):
    formula = math.sqrt((p2[0] - p1[0])** 2 + (p2[1] - p1[1])**2)
    distance = round(formula, d)
    
    return distance


coordinates=lambda p1,p2,p=0: round(((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)**0.5,p)

def coordinates(p1,p2,prec=0):
    return round( ( (p2[1]-p1[1])**2 + (p2[0]-p1[0])**2 )**0.5,prec)

from math import sqrt

def coordinates(p1, p2, precision=0):
    x1, y1 = p1
    x2, y2 = p2
    distance = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
    return round(distance, precision)