title
Python Tutorial for Beginners 8: Functions
description
In this Python Beginner Tutorial, we will begin learning how to write functions. Functions are one of the most important things to learn in Python Programming and will take us to the next level. We will learn how to create/define functions, how to pass in arguments, and also how to return values. Let's get started.
The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Python-Functions
Watch the full Python Beginner Series here:
https://www.youtube.com/playlist?list=PL-osiE80TeTskrapNbzXhwoFUiLCjGgY7
Scope Video: https://youtu.be/QVdf0LgmICw
✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms
✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join
✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
http://a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - http://coreyms.com/
My Second Channel - https://www.youtube.com/c/coreymschafer
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Instagram - https://www.instagram.com/coreymschafer/
#Python
detail
{'title': 'Python Tutorial for Beginners 8: Functions', 'heatmap': [{'end': 295.744, 'start': 269.224, 'weight': 0.761}, {'end': 479.586, 'start': 428.368, 'weight': 0.837}, {'end': 710.34, 'start': 600.186, 'weight': 0.75}, {'end': 776.014, 'start': 716.402, 'weight': 0.702}], 'summary': 'This tutorial covers functions, code reusability, return values, function chaining, parameter passing, function parameters, unpacking, leap year calculation, days and month functions, with practical examples and emphasis on understanding input and return values for practical benefits.', 'chapters': [{'end': 243.035, 'segs': [{'end': 30.344, 'src': 'embed', 'start': 0.229, 'weight': 0, 'content': [{'end': 3.631, 'text': "Hey there, how's it going everybody? In this video, we'll be learning about functions.", 'start': 0.229, 'duration': 3.402}, {'end': 8.894, 'text': 'Now functions are basically some instructions packaged together that perform a specific task.', 'start': 3.951, 'duration': 4.943}, {'end': 12.556, 'text': "So let's create our first function and see why these are so beneficial.", 'start': 9.234, 'duration': 3.322}, {'end': 18.119, 'text': "Now to create a function, we'll use the def keyword, which I believe stands for definition.", 'start': 12.956, 'duration': 5.163}, {'end': 20.921, 'text': "And let's just make a simple function here to get started.", 'start': 18.419, 'duration': 2.502}, {'end': 23.062, 'text': "I'll call this hello funk.", 'start': 21.281, 'duration': 1.781}, {'end': 30.344, 'text': "Now we have parentheses there, because that is where our parameters will go when we add those in, but we don't have any parameters just yet,", 'start': 23.502, 'duration': 6.842}], 'summary': "Introduction to functions, using 'def' keyword and creating a simple function", 'duration': 30.115, 'max_score': 0.229, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I229.jpg'}, {'end': 256.38, 'src': 'embed', 'start': 226.866, 'weight': 2, 'content': [{'end': 232.189, 'text': 'And now if we run this, then we can see that those changes are seen everywhere that the function is called.', 'start': 226.866, 'duration': 5.323}, {'end': 237.932, 'text': "Now this is called keeping your code dry, which stands for don't repeat yourself.", 'start': 232.589, 'duration': 5.343}, {'end': 243.035, 'text': "It's a common mistake for people new to programming to repeat the same things throughout their code,", 'start': 238.333, 'duration': 4.702}, {'end': 249.099, 'text': "when really they could either put their code into certain variables or functions so that it's in a single location.", 'start': 243.035, 'duration': 6.064}, {'end': 256.38, 'text': "So we saw earlier that since we aren't returning anything from our function, it was actually equal to none.", 'start': 249.679, 'duration': 6.701}], 'summary': 'Implementing code reusability to avoid repetition and maintainability, leading to improved efficiency and reduced errors.', 'duration': 29.514, 'max_score': 226.866, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I226866.jpg'}], 'start': 0.229, 'title': 'Functions and code reusability', 'summary': 'Covers functions, creation, execution, and benefits of code reusability, such as reducing manual changes and keeping the code dry.', 'chapters': [{'end': 243.035, 'start': 0.229, 'title': 'Functions and code reusability', 'summary': 'Discusses the concept of functions, how to create and execute functions, and the benefits of code reusability, such as reducing manual changes in code and keeping the code dry.', 'duration': 242.806, 'highlights': ['Functions are a set of instructions packaged together to perform a specific task. Functions are essentially a collection of instructions designed to accomplish a particular objective.', "The def keyword is used to create a function. The 'def' keyword is employed to define and create a function.", 'Using functions allows for code reusability, reducing the need to manually update code in multiple locations. Functions enable the reusability of code, diminishing the necessity for manual alterations in various parts of the codebase.', "The concept of keeping code dry, which stands for don't repeat yourself, is introduced as a best practice in programming. The principle of keeping code dry, an acronym for 'don't repeat yourself,' is emphasized as a key practice in programming."]}], 'duration': 242.806, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I229.jpg', 'highlights': ['Functions are essentially a collection of instructions designed to accomplish a particular objective.', "The 'def' keyword is employed to define and create a function.", 'Functions enable the reusability of code, diminishing the necessity for manual alterations in various parts of the codebase.', "The principle of keeping code dry, an acronym for 'don't repeat yourself,' is emphasized as a key practice in programming."]}, {'end': 377.57, 'segs': [{'end': 306.369, 'src': 'heatmap', 'start': 263.563, 'weight': 0, 'content': [{'end': 268.804, 'text': 'because it allows us to operate on some data and then pass the result to whatever called our function.', 'start': 263.563, 'duration': 5.241}, {'end': 274.926, 'text': "So instead of printing the string hello function within here, let's instead return this.", 'start': 269.224, 'duration': 5.702}, {'end': 282.552, 'text': "Okay, so what does this mean exactly? This means that when we execute our function, it's actually going to be equal to our return value.", 'start': 275.606, 'duration': 6.946}, {'end': 287.737, 'text': 'So these executed functions here are actually equal to the string hello function.', 'start': 282.933, 'duration': 4.804}, {'end': 295.744, 'text': "So right now, if we run this, then it doesn't give us any results, because it's just a string that we're not doing anything with.", 'start': 288.137, 'duration': 7.607}, {'end': 306.369, 'text': 'But if instead we print this, so let me print that executed function, and if we run that, then we can see that it prints out our string.', 'start': 296.185, 'duration': 10.184}], 'summary': 'Using return instead of print in functions allows for passing results, executing functions, and displaying output.', 'duration': 42.806, 'max_score': 263.563, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I263563.jpg'}, {'end': 354.854, 'src': 'embed', 'start': 306.749, 'weight': 1, 'content': [{'end': 312.651, 'text': 'So basically, think of a function as a machine that takes input and produces a result.', 'start': 306.749, 'duration': 5.902}, {'end': 316.873, 'text': 'When you execute a function, you can think of it almost like a black box.', 'start': 313.031, 'duration': 3.842}, {'end': 319.954, 'text': "You don't need to know exactly how it's doing what it's doing.", 'start': 317.173, 'duration': 2.781}, {'end': 323.395, 'text': "You're mainly concerned about the input and the return value.", 'start': 320.254, 'duration': 3.141}, {'end': 329.8, 'text': "So in this simple example here, we don't have any input, and we can see that the return value is a string.", 'start': 323.815, 'duration': 5.985}, {'end': 335.524, 'text': "Now, don't get me wrong it's useful to know what a function is doing, but when you're first getting started,", 'start': 330.62, 'duration': 4.904}, {'end': 340.408, 'text': "don't get caught up on understanding every detail of what every function does.", 'start': 335.524, 'duration': 4.884}, {'end': 343.069, 'text': "just focus on the input and what's returned.", 'start': 340.788, 'duration': 2.281}, {'end': 354.854, 'text': 'So, for example, when we call the len function on a string, so if I print out len of this string test, if I run this, then,', 'start': 343.509, 'duration': 11.345}], 'summary': 'Functions are like black boxes, focusing on input and return values, len function on a string returns its length.', 'duration': 48.105, 'max_score': 306.749, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I306749.jpg'}], 'start': 243.035, 'title': 'Functions and return values', 'summary': 'Explains the concept of functions and return values, emphasizing the importance of understanding input and return values rather than the internal workings of functions, illustrated through examples and emphasizing the practical benefits of this approach.', 'chapters': [{'end': 377.57, 'start': 243.035, 'title': 'Functions and return values', 'summary': 'Explains the concept of functions and return values, emphasizing the importance of understanding input and return values rather than the internal workings of functions, illustrated through examples and emphasizing the practical benefits of this approach.', 'duration': 134.535, 'highlights': ['The return value of a function allows us to operate on some data and then pass the result to whatever called our function.', 'Understanding input and return values of functions is emphasized over understanding the internal workings of functions.', 'Executing the len function on a string returns an integer, representing the number of characters in the string.']}], 'duration': 134.535, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I243035.jpg', 'highlights': ['The return value of a function allows us to operate on some data and then pass the result to whatever called our function.', 'Understanding input and return values of functions is emphasized over understanding the internal workings of functions.', 'Executing the len function on a string returns an integer, representing the number of characters in the string.']}, {'end': 526.61, 'segs': [{'end': 405.773, 'src': 'embed', 'start': 377.57, 'weight': 0, 'content': [{'end': 381.674, 'text': 'because we can treat the return value just like the data type that it is.', 'start': 377.57, 'duration': 4.104}, {'end': 385.337, 'text': 'And understanding this will allow you to chain together some functionality.', 'start': 382.114, 'duration': 3.223}, {'end': 389.2, 'text': 'So we know our hello function returns a string.', 'start': 385.737, 'duration': 3.463}, {'end': 393.283, 'text': 'So we can treat that executed function just like a string.', 'start': 389.56, 'duration': 3.723}, {'end': 399.248, 'text': 'So if we remember back to our string methods, remember that we can uppercase a string with .upper.', 'start': 393.604, 'duration': 5.644}, {'end': 405.773, 'text': 'So really, we can take this executed function and just chain .upper onto the end of it.', 'start': 399.649, 'duration': 6.124}], 'summary': 'Treating return value as data type enables chaining functionality.', 'duration': 28.203, 'max_score': 377.57, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I377570.jpg'}, {'end': 479.586, 'src': 'heatmap', 'start': 428.368, 'weight': 0.837, 'content': [{'end': 434.451, 'text': "So to be able to pass arguments to our function, we'll need to create some parameters here within our parentheses.", 'start': 428.368, 'duration': 6.083}, {'end': 439.294, 'text': "So let's say that we wanted to customize the greeting that our function returns.", 'start': 434.831, 'duration': 4.463}, {'end': 443.116, 'text': "So let's create a parameter called greeting.", 'start': 439.634, 'duration': 3.482}, {'end': 452.523, 'text': "And now within our function, we'll return a string where we use that greeting instead of our hello text that we had before.", 'start': 443.576, 'duration': 8.947}, {'end': 456.306, 'text': "So now I'll just pass this in with a .format.", 'start': 452.943, 'duration': 3.363}, {'end': 462.191, 'text': 'So now before we run this, we have to pass in that greeting argument when we execute our function.', 'start': 456.646, 'duration': 5.545}, {'end': 464.252, 'text': "If we don't, then we'll get an error.", 'start': 462.531, 'duration': 1.721}, {'end': 467.595, 'text': "So actually, let's go ahead and run this and see this error.", 'start': 464.592, 'duration': 3.003}, {'end': 476.003, 'text': 'So we can see that when we ran that, it says that hello func is missing one required positional argument, greeting.', 'start': 468.095, 'duration': 7.908}, {'end': 479.586, 'text': "So let's pass in that greeting argument to our hello function.", 'start': 476.383, 'duration': 3.203}], 'summary': 'Creating a function with a customizable greeting parameter to avoid errors while running the function.', 'duration': 51.218, 'max_score': 428.368, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I428368.jpg'}, {'end': 467.595, 'src': 'embed', 'start': 443.576, 'weight': 1, 'content': [{'end': 452.523, 'text': "And now within our function, we'll return a string where we use that greeting instead of our hello text that we had before.", 'start': 443.576, 'duration': 8.947}, {'end': 456.306, 'text': "So now I'll just pass this in with a .format.", 'start': 452.943, 'duration': 3.363}, {'end': 462.191, 'text': 'So now before we run this, we have to pass in that greeting argument when we execute our function.', 'start': 456.646, 'duration': 5.545}, {'end': 464.252, 'text': "If we don't, then we'll get an error.", 'start': 462.531, 'duration': 1.721}, {'end': 467.595, 'text': "So actually, let's go ahead and run this and see this error.", 'start': 464.592, 'duration': 3.003}], 'summary': 'Function returns string using greeting instead of hello text, requires greeting argument.', 'duration': 24.019, 'max_score': 443.576, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I443576.jpg'}, {'end': 531.052, 'src': 'embed', 'start': 507.462, 'weight': 2, 'content': [{'end': 516.085, 'text': "Its scope is only local to the function, which is nice because we don't have to worry about it affecting anything we don't want it to affect.", 'start': 507.462, 'duration': 8.623}, {'end': 519.647, 'text': 'And if you want to learn more about Python scope,', 'start': 516.486, 'duration': 3.161}, {'end': 526.61, 'text': "then I do have a detailed video going in-depth as to how that works exactly and I'll leave a link to that video in the description section below.", 'start': 519.647, 'duration': 6.963}, {'end': 531.052, 'text': 'OK, so right now, this greeting parameter is a required argument.', 'start': 527.21, 'duration': 3.842}], 'summary': "Python function scope is local, doesn't affect unwanted areas. greeting parameter is required.", 'duration': 23.59, 'max_score': 507.462, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I507462.jpg'}], 'start': 377.57, 'title': 'Python function chaining and parameter passing', 'summary': 'Demonstrates how to chain functionality in python functions using return values as data types and how to pass arguments with parameters. it also includes examples of using .format and illustrates the local scope of variables within functions.', 'chapters': [{'end': 526.61, 'start': 377.57, 'title': 'Python function chaining and parameter passing', 'summary': 'Explains how to chain functionality in python functions by treating return values as data types and how to pass arguments to functions with parameters and examples of using .format, demonstrating the local scope of variables within functions.', 'duration': 149.04, 'highlights': ['The function chaining allows treating return values as data types, enabling the chaining of functionality. Understanding how to treat return values as data types allows chaining functionality, exemplified by using the .upper method on the returned string from the executed function.', 'Demonstrates passing arguments to functions using parameters and .format method. Illustrating passing arguments to functions by creating parameters and using the .format method to customize the greeting returned by the function.', "Illustrates the local scope of variables within functions. Explaining the local scope of variables within functions, showing that the greeting variable only affects the function's scope and does not impact variables outside the function."]}], 'duration': 149.04, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I377570.jpg', 'highlights': ['The function chaining allows treating return values as data types, enabling the chaining of functionality.', 'Demonstrates passing arguments to functions using parameters and .format method.', 'Illustrates the local scope of variables within functions.']}, {'end': 937.937, 'segs': [{'end': 554.225, 'src': 'embed', 'start': 527.21, 'weight': 0, 'content': [{'end': 531.052, 'text': 'OK, so right now, this greeting parameter is a required argument.', 'start': 527.21, 'duration': 3.842}, {'end': 534.094, 'text': "And that is because it doesn't have a default value.", 'start': 531.412, 'duration': 2.682}, {'end': 541.078, 'text': "Now, if we had a default value, then it would just fall back to the default value whenever we didn't pass that argument in.", 'start': 534.494, 'duration': 6.584}, {'end': 543.279, 'text': "So let's see an example of this.", 'start': 541.518, 'duration': 1.761}, {'end': 548.442, 'text': "So let's say that we also want to be able to pass a name to our hello function.", 'start': 543.679, 'duration': 4.763}, {'end': 551.143, 'text': 'And it will return a greeting and the name.', 'start': 548.802, 'duration': 2.341}, {'end': 554.225, 'text': 'So we can add that to our parameters.', 'start': 551.563, 'duration': 2.662}], 'summary': 'Explaining the importance of default values for parameters in functions.', 'duration': 27.015, 'max_score': 527.21, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I527210.jpg'}, {'end': 710.34, 'src': 'heatmap', 'start': 600.186, 'weight': 0.75, 'content': [{'end': 604.35, 'text': 'But if we want to pass in a value, then it will use that value instead.', 'start': 600.186, 'duration': 4.164}, {'end': 611.876, 'text': "So when we execute this function, if I was to say name is equal to, we'll say Corey and run that.", 'start': 604.71, 'duration': 7.166}, {'end': 615.998, 'text': 'And now we can see that it printed out the greeting with the name that we passed in.', 'start': 612.316, 'duration': 3.682}, {'end': 622.242, 'text': 'Now, your required positional arguments have to come before your keyword arguments.', 'start': 617.019, 'duration': 5.223}, {'end': 627.004, 'text': "Now, if you try to create a function with those out of order, then it's going to give you an error.", 'start': 622.602, 'duration': 4.402}, {'end': 631.287, 'text': 'Now, this is a little more advanced topic that trips a lot of people up.', 'start': 627.505, 'duration': 3.782}, {'end': 637.709, 'text': "But at some point, you'll probably run across a function in Python that looks something like this.", 'start': 631.607, 'duration': 6.102}, {'end': 640.57, 'text': "So I'll say def student info.", 'start': 637.749, 'duration': 2.821}, {'end': 647.132, 'text': 'And you might see something where you see this star args and star star quarks.', 'start': 641.07, 'duration': 6.062}, {'end': 648.953, 'text': 'And so let me just go ahead.', 'start': 647.632, 'duration': 1.321}, {'end': 653.854, 'text': 'And within this new function here, I will print out args.', 'start': 649.473, 'duration': 4.381}, {'end': 656.515, 'text': "And I'll also print out quarks.", 'start': 654.034, 'duration': 2.481}, {'end': 659.316, 'text': "So let's not really worry about this function name for now.", 'start': 656.975, 'duration': 2.341}, {'end': 661.658, 'text': "It's the arguments that I want to focus on.", 'start': 659.716, 'duration': 1.942}, {'end': 667.523, 'text': 'So seeing this star args and star star quargs can seem confusing at first,', 'start': 662.058, 'duration': 5.465}, {'end': 674.67, 'text': "but basically all it's doing is allowing us to accept an arbitrary number of positional or keyword arguments.", 'start': 667.523, 'duration': 7.147}, {'end': 683.713, 'text': "So, for example, Let's say that this student info function takes positional arguments that represent the classes that the student is taking,", 'start': 675.03, 'duration': 8.683}, {'end': 688.854, 'text': 'plus the keyword arguments passed in will be random information about the student.', 'start': 683.713, 'duration': 5.141}, {'end': 695.596, 'text': "So you can see in both of those examples, we don't know how many of these positional or keyword arguments there will be.", 'start': 689.214, 'duration': 6.382}, {'end': 703.458, 'text': "and that's why we use star args and star star quarks, and the names don't have to be args and quarks.", 'start': 696.136, 'duration': 7.322}, {'end': 705.819, 'text': "but that's a convention that you'll see a lot.", 'start': 703.458, 'duration': 2.361}, {'end': 710.34, 'text': "so it's always good to stick with convention so that people can understand your code.", 'start': 705.819, 'duration': 4.521}], 'summary': 'Python functions can accept arbitrary positional or keyword arguments using star args and star star quarks.', 'duration': 110.154, 'max_score': 600.186, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I600186.jpg'}, {'end': 647.132, 'src': 'embed', 'start': 617.019, 'weight': 3, 'content': [{'end': 622.242, 'text': 'Now, your required positional arguments have to come before your keyword arguments.', 'start': 617.019, 'duration': 5.223}, {'end': 627.004, 'text': "Now, if you try to create a function with those out of order, then it's going to give you an error.", 'start': 622.602, 'duration': 4.402}, {'end': 631.287, 'text': 'Now, this is a little more advanced topic that trips a lot of people up.', 'start': 627.505, 'duration': 3.782}, {'end': 637.709, 'text': "But at some point, you'll probably run across a function in Python that looks something like this.", 'start': 631.607, 'duration': 6.102}, {'end': 640.57, 'text': "So I'll say def student info.", 'start': 637.749, 'duration': 2.821}, {'end': 647.132, 'text': 'And you might see something where you see this star args and star star quarks.', 'start': 641.07, 'duration': 6.062}], 'summary': 'Positional arguments must come before keyword arguments in python functions.', 'duration': 30.113, 'max_score': 617.019, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I617019.jpg'}, {'end': 695.596, 'src': 'embed', 'start': 667.523, 'weight': 1, 'content': [{'end': 674.67, 'text': "but basically all it's doing is allowing us to accept an arbitrary number of positional or keyword arguments.", 'start': 667.523, 'duration': 7.147}, {'end': 683.713, 'text': "So, for example, Let's say that this student info function takes positional arguments that represent the classes that the student is taking,", 'start': 675.03, 'duration': 8.683}, {'end': 688.854, 'text': 'plus the keyword arguments passed in will be random information about the student.', 'start': 683.713, 'duration': 5.141}, {'end': 695.596, 'text': "So you can see in both of those examples, we don't know how many of these positional or keyword arguments there will be.", 'start': 689.214, 'duration': 6.382}], 'summary': 'Function allows accepting arbitrary number of positional or keyword arguments for student info.', 'duration': 28.073, 'max_score': 667.523, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I667523.jpg'}, {'end': 776.014, 'src': 'heatmap', 'start': 716.402, 'weight': 0.702, 'content': [{'end': 721.063, 'text': "and first we want to pass in some positional arguments of the classes that they're taking.", 'start': 716.402, 'duration': 4.661}, {'end': 728.768, 'text': "so we'll say math and art, And now for our keyword arguments, we'll pass in some random information about the student.", 'start': 721.063, 'duration': 7.705}, {'end': 730.77, 'text': "So we'll say name is equal to John.", 'start': 728.788, 'duration': 1.982}, {'end': 734.022, 'text': 'and age is equal to 22.', 'start': 731.34, 'duration': 2.682}, {'end': 744.169, 'text': "So now, if we run this, then we can see that when we printed the args, it's actually a tuple with all of our positional arguments,", 'start': 734.022, 'duration': 10.147}, {'end': 749.652, 'text': 'and our quarks are a dictionary with all of our keyword values.', 'start': 744.169, 'duration': 5.483}, {'end': 754.936, 'text': "So once you have that tuple and that dictionary, then you'll be able to do whatever you want with that information.", 'start': 750.033, 'duration': 4.903}, {'end': 760.661, 'text': 'Now, sometimes you might see a function call with arguments using the star or double star.', 'start': 755.316, 'duration': 5.345}, {'end': 769.929, 'text': "Now, when it's used in that context, it will actually unpack a sequence or dictionary and pass those values into the function individually.", 'start': 761.081, 'duration': 8.848}, {'end': 776.014, 'text': "So to see what I mean, let's make a list and a dictionary of everything that we just passed into our function.", 'start': 770.309, 'duration': 5.705}], 'summary': 'Passing positional and keyword arguments in python function, unpacking using star and double star.', 'duration': 59.612, 'max_score': 716.402, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I716402.jpg'}, {'end': 781.521, 'src': 'embed', 'start': 755.316, 'weight': 2, 'content': [{'end': 760.661, 'text': 'Now, sometimes you might see a function call with arguments using the star or double star.', 'start': 755.316, 'duration': 5.345}, {'end': 769.929, 'text': "Now, when it's used in that context, it will actually unpack a sequence or dictionary and pass those values into the function individually.", 'start': 761.081, 'duration': 8.848}, {'end': 776.014, 'text': "So to see what I mean, let's make a list and a dictionary of everything that we just passed into our function.", 'start': 770.309, 'duration': 5.705}, {'end': 781.521, 'text': "And just to clear up some room here, I'm going to go ahead and delete the hello function that we started off with.", 'start': 776.474, 'duration': 5.047}], 'summary': 'Function call with star or double star unpacks sequence or dictionary into individual values.', 'duration': 26.205, 'max_score': 755.316, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I755316.jpg'}], 'start': 527.21, 'title': 'Function parameters and unpacking', 'summary': 'Explains setting default parameter values, function execution impact, and usage of *args and **kwargs to accept arbitrary arguments, and unpacking of sequences and dictionaries using * and ** in python functions.', 'chapters': [{'end': 615.998, 'start': 527.21, 'title': 'Default parameter value in function', 'summary': "Explains the concept of default parameter value in a function, demonstrating how to set a default value for a parameter and its impact on function execution, with an example of using the default value 'u' when no name argument is passed and using the passed value when provided. it also showcases how the default parameter value functionality works in the code.", 'duration': 88.788, 'highlights': ["The chapter explains the concept of default parameter value in a function, demonstrating how to set a default value for a parameter and its impact on function execution, with an example of using the default value 'u' when no name argument is passed and using the passed value when provided.", 'It also showcases how the default parameter value functionality works in the code.', 'The greeting parameter is a required argument without a default value, but if a default value is set, it will fall back to the default value when the argument is not passed.', "The example demonstrates the usage of a default value 'u' for the name parameter, where the function uses the default value when no name is passed and uses the passed value when provided."]}, {'end': 937.937, 'start': 617.019, 'title': 'Python function arguments and unpacking', 'summary': 'Discusses the order of positional and keyword arguments in python functions, the usage of *args and **kwargs to accept arbitrary number of arguments, and the unpacking of sequence or dictionary using * and **. it also demonstrates the understanding of code from python standard library.', 'duration': 320.918, 'highlights': ['The order of positional and keyword arguments is crucial in Python functions, with required positional arguments preceding keyword arguments. The transcript emphasizes the importance of placing required positional arguments before keyword arguments in Python functions, as creating a function with these arguments out of order will result in an error.', "Usage of *args and **kwargs to accept an arbitrary number of positional or keyword arguments in functions. The chapter explains the purpose of using *args and **kwargs, which allows the function to accept an arbitrary number of positional or keyword arguments, enabling flexibility in the function's parameter inputs.", 'Demonstration of unpacking a sequence or dictionary using * and ** to pass values into a function individually. The transcript provides examples of using * and ** to unpack a sequence or dictionary, showcasing how these operators enable the passing of values into a function individually, providing clarity on their usage.', 'Understanding and modifying code from the Python standard library, showcasing the grasp of fundamental concepts. The chapter demonstrates the ability to understand and modify code from the Python standard library, highlighting the proficiency gained in fundamental concepts and their application in practical scenarios.']}], 'duration': 410.727, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I527210.jpg', 'highlights': ["The chapter explains the concept of default parameter value in a function, demonstrating how to set a default value for a parameter and its impact on function execution, with an example of using the default value 'u' when no name argument is passed and using the passed value when provided.", "Usage of *args and **kwargs to accept an arbitrary number of positional or keyword arguments in functions. The chapter explains the purpose of using *args and **kwargs, which allows the function to accept an arbitrary number of positional or keyword arguments, enabling flexibility in the function's parameter inputs.", 'Demonstration of unpacking a sequence or dictionary using * and ** to pass values into a function individually. The transcript provides examples of using * and ** to unpack a sequence or dictionary, showcasing how these operators enable the passing of values into a function individually, providing clarity on their usage.', 'The order of positional and keyword arguments is crucial in Python functions, with required positional arguments preceding keyword arguments. The transcript emphasizes the importance of placing required positional arguments before keyword arguments in Python functions, as creating a function with these arguments out of order will result in an error.']}, {'end': 1294.928, 'segs': [{'end': 1002.705, 'src': 'embed', 'start': 977.388, 'weight': 0, 'content': [{'end': 984.452, 'text': "So it's a good practice anytime you write a function to write a docstring that goes along with it, explaining what that function is supposed to do.", 'start': 977.388, 'duration': 7.064}, {'end': 991.317, 'text': "Now, this part here can seem a little intimidating, but it's not important that you understand how a leap year is calculated.", 'start': 984.992, 'duration': 6.325}, {'end': 993.959, 'text': "There's not a lot of people who know that off the top of their head.", 'start': 991.357, 'duration': 2.602}, {'end': 997.621, 'text': 'But for various reasons, this is how a leap year is calculated.', 'start': 994.579, 'duration': 3.042}, {'end': 1002.705, 'text': "And it's not important, but you could probably figure out what this conditional is doing.", 'start': 998.042, 'duration': 4.663}], 'summary': 'Writing a docstring for functions is a good practice. understanding leap year calculation is not crucial.', 'duration': 25.317, 'max_score': 977.388, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I977388.jpg'}, {'end': 1134.782, 'src': 'embed', 'start': 1108.407, 'weight': 1, 'content': [{'end': 1115.33, 'text': "But now let's try our days and month function, which is going to be a little bit longer of a walkthrough.", 'start': 1108.407, 'duration': 6.923}, {'end': 1119.712, 'text': "So we'll say days and month, and we'll pass in a year.", 'start': 1115.67, 'duration': 4.042}, {'end': 1121.092, 'text': 'So it takes a year first.', 'start': 1119.872, 'duration': 1.22}, {'end': 1125.994, 'text': "We'll pass in a year of 2017, and we'll pass in a month of 2020.", 'start': 1121.112, 'duration': 4.882}, {'end': 1126.995, 'text': '2, which is February.', 'start': 1125.994, 'duration': 1.001}, {'end': 1134.782, 'text': 'Now since 2017 is not a leap year, then this second month, which is February, should only have 28 days.', 'start': 1127.336, 'duration': 7.446}], 'summary': 'The function calculates the number of days in a specific month of a given year, such as 28 days in february 2017.', 'duration': 26.375, 'max_score': 1108.407, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I1108407.jpg'}, {'end': 1280.159, 'src': 'embed', 'start': 1254.195, 'weight': 2, 'content': [{'end': 1261.183, 'text': 'I hope that now you have a clear understanding of how functions work, how we return values, and the different ways that we can pass arguments.', 'start': 1254.195, 'duration': 6.988}, {'end': 1268.693, 'text': "In the next video, we'll be learning how to import modules and also learn about some of the useful modules that come in the standard library.", 'start': 1261.544, 'duration': 7.149}, {'end': 1274.496, 'text': 'But if anyone has any questions about what we covered in this video, then feel free to ask in the comment section below,', 'start': 1269.073, 'duration': 5.423}, {'end': 1275.737, 'text': "and I'll do my best to answer those.", 'start': 1274.496, 'duration': 1.241}, {'end': 1280.159, 'text': 'And if you enjoy these tutorials and would like to support them, then there are several ways you can do that.', 'start': 1276.197, 'duration': 3.962}], 'summary': 'Understanding functions, return values, passing arguments. next: importing modules, useful standard library modules.', 'duration': 25.964, 'max_score': 1254.195, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I1254195.jpg'}], 'start': 938.377, 'title': 'Leap year, days and month functions', 'summary': 'Explains leap year calculation, days and month function walkthrough, and understanding functions and importing modules. it includes examples like checking if 2020 is a leap year, determining days in a non-leap year, and covers importing modules and tutorial support.', 'chapters': [{'end': 1107.987, 'start': 938.377, 'title': 'Leap year calculation', 'summary': 'Explains how to calculate leap years, including the use of a docstring to document a function and a days and month function that returns the number of days in a month, with an example of using the isleap function to check if 2020 is a leap year.', 'duration': 169.61, 'highlights': ['The chapter explains how to calculate leap years, including the use of a docstring to document a function and a days and month function that returns the number of days in a month It covers the explanation of leap year calculation, the importance of docstring, and the function that returns the number of days in a month.', 'Example of using the isLeap function to check if 2020 is a leap year It demonstrates using the isLeap function to check if 2020 is a leap year, which returns true.', "Explanation of how the isLeap function determines if a year is a leap year The isLeap function checks if a year is divisible by four, not divisible by 100, or divisible by 400 to determine if it's a leap year."]}, {'end': 1239.628, 'start': 1108.407, 'title': 'Days and month function walkthrough', 'summary': 'Walks through a function called days and month which takes a year and a month as input and determines the number of days in that month for the given year, using the example of 2017 and february (month 2) as a non-leap year, resulting in 28 days.', 'duration': 131.221, 'highlights': ["The function 'days and month' is demonstrated using the example of 2017 and February (month 2) as a non-leap year, resulting in 28 days. 2017, February, 28 days", "The explanation of the function's process involves checking the month range, evaluating leap year status, and accessing the month days list to determine the days in the month. Month range check, leap year evaluation, accessing month days list", "The function's process is clarified by walking through the code execution step by step, ensuring understanding of the logic and results. Step-by-step code execution explanation"]}, {'end': 1294.928, 'start': 1240.008, 'title': 'Understanding functions and importing modules', 'summary': 'Covers the understanding of how functions work, returning values, and passing arguments, with a preview of importing modules and supporting the tutorials through likes, shares, and contributions.', 'duration': 54.92, 'highlights': ['The chapter covers the understanding of how functions work, returning values, and passing arguments, with a preview of importing modules and supporting the tutorials through likes, shares, and contributions.', 'The next video will cover learning how to import modules and also learn about some of the useful modules that come in the standard library.', 'The easiest way to support the tutorials is by liking the video and giving it a thumbs up, as well as sharing the videos with anyone who would find them useful.', 'Viewers can also support the tutorials through Patreon by contributing, with a link to the page provided in the description section below.']}], 'duration': 356.551, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/9Os0o3wzS_I/pics/9Os0o3wzS_I938377.jpg', 'highlights': ['The chapter explains how to calculate leap years, including the use of a docstring to document a function and a days and month function that returns the number of days in a month', "The function 'days and month' is demonstrated using the example of 2017 and February (month 2) as a non-leap year, resulting in 28 days", 'The chapter covers the understanding of how functions work, returning values, and passing arguments, with a preview of importing modules and supporting the tutorials through likes, shares, and contributions']}], 'highlights': ['Functions enable the reusability of code, diminishing the necessity for manual alterations in various parts of the codebase.', "The principle of keeping code dry, an acronym for 'don't repeat yourself,' is emphasized as a key practice in programming.", 'The return value of a function allows us to operate on some data and then pass the result to whatever called our function.', 'Understanding input and return values of functions is emphasized over understanding the internal workings of functions.', 'The function chaining allows treating return values as data types, enabling the chaining of functionality.', 'Demonstrates passing arguments to functions using parameters and .format method.', "The chapter explains the concept of default parameter value in a function, demonstrating how to set a default value for a parameter and its impact on function execution, with an example of using the default value 'u' when no name argument is passed and using the passed value when provided.", "Usage of *args and **kwargs to accept an arbitrary number of positional or keyword arguments in functions. The chapter explains the purpose of using *args and **kwargs, which allows the function to accept an arbitrary number of positional or keyword arguments, enabling flexibility in the function's parameter inputs.", 'Demonstration of unpacking a sequence or dictionary using * and ** to pass values into a function individually. The transcript provides examples of using * and ** to unpack a sequence or dictionary, showcasing how these operators enable the passing of values into a function individually, providing clarity on their usage.', 'The order of positional and keyword arguments is crucial in Python functions, with required positional arguments preceding keyword arguments. The transcript emphasizes the importance of placing required positional arguments before keyword arguments in Python functions, as creating a function with these arguments out of order will result in an error.', 'The chapter explains how to calculate leap years, including the use of a docstring to document a function and a days and month function that returns the number of days in a month', "The function 'days and month' is demonstrated using the example of 2017 and February (month 2) as a non-leap year, resulting in 28 days", 'The chapter covers the understanding of how functions work, returning values, and passing arguments, with a preview of importing modules and supporting the tutorials through likes, shares, and contributions']}