We’ll start Day 17 by looking at another type of argument: optional arguments that have a default value.
Introducing Default Arguments
00:00 You’ve seen how arguments and Python functions can be either positional or keyword arguments, and often you have a choice of which one to use, although not always, as you’ll see later on this week as well.
00:13 But so far, all the parameters in a function are mandatory. So when you call the function, you have to put all of those arguments in. However, you can also have arguments that are optional.
00:25 And in order to do this, you need to give them a default value. And today you have a look at how when you define a function, you can, with certain parameters, give them a default value.
00:35 And that means that they’re optional. You can either put them in or not. And this gives more flexibility. When you’re writing a function, you’re making it more flexible on how your user can use it.
00:45 However, there are some pitfalls when dealing with default values in functions. You’ll have a look at that again today. And here we’re going to revisit one of the characteristics we talked a lot about.
00:57 A data type can be mutable or immutable. And we’re going to start understanding a bit more what’s happening in functions behind the scenes
01:10 when you talk about, when you talk about what type of values you can use as the default values. Today we’ll be sort of opening the lid to how functions work.
01:21 And then we’re going to go deeper later this week and next week.
You must own this product to join the conversation.