For Loops

5 main for loops is python

1) Regular loop

2) List loop

3) Enumeration loop

4) List Comprehension loop

5) Double for loop

Booleans and if statments

Nested if

Problems

Problem 1

The equation for the height of a thrown ball is $y = -1/2 g t^2 + v_0 t$ where

Problem 2

Problem 3

Sum numbers from 1 to 1000, except for those that can be divided by 3, and those that can be divided by 7

Python While Loops

Nested while Loops

Functions

Positional arguments of the function:

Keyword arguments of the function:

Returning multiple values as a tuple

Anonymous (Lambda) Functions

Why Use Lambda Functions?

The power of lambda is better shown when you use them as an anonymous function inside another function.

Multiple valued lambda function

Partial Argument Application of Lambda Function

iter function

Generators

A generator is a concise way to contruct an iterable object. Normal functions execute and return a single object (this can be a list or tuple that contains multiple things). Generators return a sequence of values, but lazily; they pause at each one untill the next one is requested. This can save computation space. To create a generator, use the "yield" keyword.

Generator Expressions

Like lambda functions for functions, there are more concise way to make generators as well. This involves using a generator expression like such:

itertools module

Python’s Itertool is a module that provides various functions that work on iterators to produce complex iterators.