Learn Python: Function Arguments

Use the full potential of Python functions. Learn about different ways to declare, call, and interact with functions!

Start[missing "en.views.course_landing_page.learn-python-3.course_illustration" translation]
Learn Python: Function Arguments
Lesson 1 of 1
  1. 1

    Python's functions offer us a very expressive syntax. We're going to look into some of the finer details of how functions in Python work and some techniques we can use to be more intuitive while w...

  2. 2

    How do you define a variable that you can't assign a value to yet? You use [...] . [...] is a special value in Python. It is unique (there can't be two different [...] s) and immutable (you c...

  3. 3

    What does a function return when it doesn't return anything? This sounds like a riddle, but there is a correct answer. A Python function that does not have any explicit [...] statement will retur...

  4. 4

    Function arguments are required in Python. So a standard function definition that defines two parameters requires two arguments passed into the function. [...] Above we defined our function, [...

  5. 5

    Not all of your arguments need to have default values. But Python will only accept functions defined with their parameters in a specific order. The required parameters need to occur before any para...

  6. 6

    When we call a function in Python, we need to list the arguments to that function to match the order of the parameters in the function definition. We don't necessarily need to do this if we pass ke...

  7. 7

    When writing a function with default arguments, it can be tempting to include an empty list as a default argument to that function. Let's say you have a function called [...] that has two require...

  8. 8

    So if we can't use a list as a default argument for a function, what can we use? If we want an empty list, we can use [...] as a special value to indicate we did not receive anything. After we ch...

  9. 9

    A Python function can return multiple things. This is especially useful in cases where bundling data into a different structure (a dictionary or a list, for instance) would be excessive. In Python ...

  10. 10

    We don't always know how many arguments a function is going to receive, and sometimes we want to handle any possibility that comes at us. Python gives us two methods of unpacking arguments provided...

  11. 11

    Python doesn't stop at allowing us to accept unlimited positional parameters, it gives us the power to define functions with unlimited keyword parameters too. The syntax is very similar, but uses t...

  12. 12

    This keyword argument unpacking syntax can be used even if the function takes other parameters. However, the parameters must be listed in this order: All named positional parameters An unpacke...

  13. 13

    Not only can we accept arbitrarily many parameters to a function in our definition, but Python also supports a syntax that makes deconstructing any data that you have on hand to feed into a functi...

  14. 14

    We covered a lot of ground in this lesson! We learned all about how functions can accept different arguments and different styles by which we can pass those arguments in. We covered: * The default ...

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo

Learn Python: Function Arguments

Start[missing "en.views.course_landing_page.learn-python-3.course_illustration" translation]