Functions with optional arguments

In the previous lecture we noticed that the pow function could get an optional argument. Run the code below to print out the documentation of pow again.

As you can see in the documentation, the third z argument has a default value. That means if we don't pass a third argument when we call pow, that third argument argument will keep the default value, in this case a None value which is a special Python object that basically means an empty value. The third argument is actually the modulus value, which means if we pass it, the pow function will return the output of the formula  x y % z . Let us try that:


Run that and you will see that we get 0 as output which is the product of the math operation  2 3 % 4 . but don't worry if you understand the math formula. What is important is to understand that we were able to provide a value of 4 for the third argument of the pow function.


Next Lecture
Recommended Course

Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.