Python 3 Programming Tutorial - Function Parameter Defaults

preview_player
Показать описание
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.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

seriously...your instructional videos are better than what my college professor teaches. Thank you for taking the time to do these.... these are the best PY tutorials out there.

mprent
Автор

This might be important: All required paramteres must be placed before any default arguments.

MrSarky
Автор

Thank you for these tutorials because these are so far some of the best ones I have come across so far. I've tried others but they don't always explain the stuff like they should. I have also recomended these videos as well as some others of yours to other people. :) Thank You.

jasonhogan
Автор

Hey, I'm new to programming and I must say you are the best teacher I've ever seen!!! I've watched about ten other YouTubers that do what you do and none of them teach as good as you. I have learned all my coding from you and I have made my own games from all the things you have taught me. I really appreciate that you love to help.

lavaseer
Автор

Starting with one video per day, so in 68 days i hopefully know Python 3!

bjorne
Автор

I just started learning Python and your tutorials are the easiest and simplest to understand so far! (working with python3.6). You honestly teach better than my programming teachers! Thank you for taking the time to make this, it means a lot!

PaperSparks
Автор

really i wanted to learn python ... i have seen many other youtube channels... this is the best..pllease keep continuing ur great work..i will recommend this awesom channel to my colleagues

priyadharshinijayakumar
Автор

Thank you very much sentdex. Your tutorials helps a lot, you can teach very good and it makes fun to listen to you. Again, thank you!

VeniVidiVici
Автор

I like the way of your teaching. I have learnt python and Django only from your videos. Hoping for more videos on Django! :)

AlfranAli
Автор

I am new to parameters, so after looking at your video, i worked out that you can do this:
def simple_addition (number_one, number_two):
    answer = number_one + number_two
    print (number_one, "+", number_two, "=", answer)

simple_addition (number_one = int(input ("Say a number...")), number_two = int(input("Say another number...")))

this asks for 2 numbers and then adds them...
(The spacing may mess up as this is in youtube comments)

Silentwhacky
Автор

sir in function default parameters 10th video what is use of giving pass to the function simple....??

arpitpandey
Автор

I'm getting an error that doesnt let me run the program:
"positional argument follows keyword argument"
Do you know what it means, or any idea of why it's caused?

Freedster
Автор

Man you are the saviour. Thanks a lot and appreciate your work.

WarTornPH
Автор

you can also write return in stead of pass.

ryansean
Автор

4:30 WHERE'S THE LOVE FOR WINGDINGS!?!

michaeldemarco
Автор

You are the great. You are even better than my college and my private institute teacher.
But I want you to ask what is the first function definition is for in this video tutorial.

hriteekbista
Автор

question: at 5:00 you changed bgc's value to 'b' in the calling function. now, first a function is called and then it is executed. so when it is executed, control goes to the part where function is defined. so why is bgc's value changed to 'b' when it it's default is 'w' in the defined function?

punpompur
Автор

how does it print a then w when it is given as basic_window(500, 350, 'a')

priyadharshinijayakumar
Автор

when do you need to put space in between or when you don't need space in between?

lemyul
Автор

Excuse me.. what is wrong with webdings?

comradejames