Default arguments

Some functions in Python take a long list of arguments, and in most cases, it’s convenient to have default values for those arguments. For example, the default value for the end parameter of the print() function is \n - a new line. But if someone wants to print another symbol in the end, they can provide it with end='*', for instance. We can define default arguments in our functions as well:
def work(hours, from_home=True):
	if from_home:
		print('Home sweet home...')
	else:
		print("Let's meet some people!")
	return hours - 2

work(8)
work(8, True)
work(8, False)
In this example, we have to provide the number of hours to the work() function, but we can skip the from_home parameter. If we don’t provide it, it will be set to True as we have defined the function as def work(hours, from_home=True).
 

Challenge

Fill in the function to produce the correct result. The function should compute the distance between two points and . In some cases, the second coordinate is omitted, and therefore, the distance should be computed from the origin of the coordinate system - .
The function should accept 4 arguments and return the distance between those.
As a reminder, the distance between two points can be calculated with:
Input
Output
0 1
1
1 1 1 2
1
 

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