Why: Python Functions, Calling Function, Arguments & Parameters? (W/ Mnemonics)
Channel: Mnemonic Academy
Date: 06/05/2017

Get The Full “Learn Python 🐍” Online Course: 
http://www.mnemonic.academy/learn-python

The following video is from an online educational course produced by Mnemonic Academy that teaches the basics of Python programming using mnemonics, metaphors and the science of learning titled “Learn Python: Like a Bee Student”, taught by instructor Dylan Jorgensen

What’s a function?
- It’s a structure for containing a block of code.
Once contained it will only be executed when called.
- The contained block of code can perform logic and previously defined variables or new variables that are passed in at the time of the call
- It can return an output that can be saved in a new variable at the call location.

What's the point?
- Functions are arguably the most important concept in computer science, programming and mathematics. This is because they allow us to generalize transformations can be used over and over. 
- Putting functions together is what bring computers to life, they let us stand on the shoulders of giants. Countless programmers have (generously) already defined the logic in lower level function we use every day to simplify the mind bogglingly complex logic our computers process constantly.
- Bonus Thought: An open source programming language like Python is really a beautiful example of humanity coming together. It’s great that everyone contributes so everyone can benefit.

What syntax is required to build a valid function?
- Keyword "def" (short for "define a function")
- Unique function name
- Parenthesis for optional arguments
- Ending colon:
- Indentation
- Pass, logic or return

Why do we use the "def" abbreviation to define a function?
- “Def” is short for definition, and represents the full phrase “define a function”

What does it mean to call a function?
- When we "call" a function we are asking the function to execute logic stored inside of it. 
- Optionally we can pass in an argument or have it return to us a variable.

What is the syntax that is required to call a function?
- Calling a function can be done by typing the name of the function without the “def” part and adding parenthesis at the end”

How can we get changes back from our function?
- The keywords “pass” and “return” let us get either nothing or something back from our function.

What is a parameter?
 -A parameter is a variable of potentially any type.

Is there a difference between parameters and arguments?
- Yes, but a small difference
- Parameters are the names of variables accepted for input in the definition of a function.
- Arguments are the variables passed into an invoked function:

What are *args and **kwargs?
- They are arguments of varying lengths.
- *args allows you pass an arbitrary number of positional arguments into your function.
- Similarly, **kwargs allows you to pass an arbitrary number of dictionary key-value pairs.

Photos under creative commons licence are links to the original source from the Learn Python: E-Book. https://goo.gl/BAMwi6, https://goo.gl/K1xRFv, https://goo.gl/9k2MY3

Interested in Learning More About Online Courses That Teach Using Mnemonics, Metaphors and the Science of Learning?

Checkout All Our Mnemonic Academy 🐝 Online Courses: 
http://www.mnemonic.academy

Subscribe To Our Mnemonic Academy 🐝 YouTube Channel:
https://www.youtube.com/channel/UCrZjSLS1o3FJDS5hFoTCIPQ

Like Our Mnemonic Academy 🐝 Facebook Page:
https://www.facebook.com/www.mnemonic.academy