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
c = math.floor(3.4) # Floor function => 3
d = math.round(3.4) # Round 3.4 => 3
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, round
# 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
d = round(3.4) # Round 3.4 => 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
3
4
1
0.5

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