math

Python built-in functions are very useful for performing generic operations but sometimes more specialized operations are needed. Those are usually packaged in modules. Python is well known for a wide variety of helpful modules and libraries that support many operations out of the box.
To use modules in python, we need to import them first and use the functions inside of them afterward:
import math

a = math.sqrt(3)    # Square root of 3 => 1.73205080757
b = math.ceil(3.4)  # Ceiling function => 4 (round up)
c = math.floor(3.4) # Floor function => 3   (round down)
All the functions in the math module are available through math.FUNCTION_NAME. If one does not want to write math. at the beginning of each function, those functions can be imported at the beginning:
from math import sqrt, ceil, floor
# from math import *  # Or we can import everything (this is a bad practice)

a = sqrt(3)    # Square root of 3 => 1.73205080757
b = ceil(3.4)  # Ceiling function => 4
c = floor(3.4) # Floor function => 3
The whole list of functions supported by math can be found on the main python website: https://docs.python.org/3/library/math.html
 

Challenge

The standard Euclidean distance is defined as . Given two points, calculate their Euclidean distance.
The input consists of 4 numbers: and coordinates of the first point followed by and coordinates of the second point. The program should output the Euclidean distance between those two points.
Input
Output
3 4 1 0.5
4.031128874149275
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue