Python 3 Programming Tutorial - Function Parameter Defaults

Channel:
Subscribers:
1,410,000
Published on ● Video Link: https://www.youtube.com/watch?v=KeRxe9rll2Q



Category:
Tutorial
Duration: 6:06
188,278 views
1,621


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







Tags:
Computer Programming (Professional Field)
Python (Software)
programming
tutorial
basics
python 3
python 3.3
python 3.4
python 2 and 3
python 2.7
2.7
3.3
3.4
beginner
how-to
coding
easy
function
parameter
Python (Programming Language)
Computer Programming (Conference Subject)