In the last tutorial, we explained what function parameters were, and that we could have an infinite amount of them. With this, we explained how having a lot of them could become troublesome and tedious for the programmer using the function. Luckily, there is a solution for this. Sometimes, it can make a lot of sense to make a complex function highly customize-able. That said, some people may want to use the function in it's simple... "default" ... form. Think about it like buying a car. Some people want to just buy the base model, with all the features that come by default from the factory. Other people want to customize their car in many different ways. Luckily, we allow people who want to customize their car the option to do it, but we do not ask every buyer of every car what kind of wheels they want, what brand of tire, what screws they want, what kind of leather seats by what brand, what windshield, what steering wheel, what lights... etc. This is just too much for some people and what they want to use the car for. Same goes for functions in programming.
So we have function parameter defaults, which allow the function's creator to set "default" values to the function parameters. This allows anyone to use a function with the default values, yet lets anyone who wishes to customize them the ability to specify different values.
When using defaults, any parameters with defaults should be the last ones listed in the function's parameters.
Sample code for this basics series:
http://pythonprogramming.net/beginner-python-programming-tutorials/
Python 3 Programming tutorial Playlist:
http://www.youtube.com/watch?v=oVp1vrfL_w4&feature=share&list=PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M
http://seaofbtc.com
http://sentdex.com
http://hkinsley.com
https://twitter.com/sentdex
Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6