Why: Python Recursion, Iteration, Iterable, Generators, Yield & Comprehensions? (W/ Mnemonics)
Channel: Mnemonic Academy
Date: 02/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 the difference between “recursion” and “iteration”?
- When a function needs to call itself in order to solve a problem, is called recursion. Recursion means, "to run back" in Latin. 
- Iteration is a general term for taking each item of something, one after another. Any time you use a loop, explicit or implicit, to go over a group of items, that is iteration.

What’s the difference between Iterable objects and Iterator objects?
- They are both defined by general properties that we can use as a question to ask if a  Python object type has. But they are different properties so they ask different questions.
- If we want to know if an object is iterable we are asking, “can it be looped over?” Meaning anything that can appear on the right side of a for loop. Python lists, tuples, dicts and sets are all examples of inbuilt iterable.
- If we want to know if an object is iterator we are asking, “can it be run asynchronously?” Meaning it can be paused, then later remember where in the sequence it was paused then restart at that point. Think, list like objects that can pause and resume.

What's a generator?
- It’s a specific type of object in Python. 
- The term generator is an abbreviation for generator-iterators. 
- It's a special type of object that can be paused and restarted. 
- It holds the logic that it needs to do for each element separately,  so that they can be individually. 

What syntax is required?
- A special statement called "yield" is only used with generator functions.
- Python functions like next() & iter() can only be used on iterator objects that come from generators.

What’s a comprehension?
- It’s a system for shorthand notation that simplifies the syntax for working with certain constructions and types.
- They are most commonly used with group types like lists, and sets. 
- What object types can we use them with?
- They are most commonly used with group types.
- Lists, dicts, sets and generators.
Iterable objects and Iterator objects

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