Python Features Overview
Python Features Overview
bit.ly/CrashCourseADSA
bit.ly/ADSAPythonRefresh
Python Basics
- Variables
- Logic & Conditionals
Refresher -
-
Lists
Loops
- Functions
Notebook: https://goo.gl/gqLJCv
Variables
- Not strongly typed
- Built in Python functions that work across most
variable types
- Cast a variable to a different type
- Null/NaN values
- Swapping values between variables
Logic &
- Python uses the full words for most logical
operators
Conditionals -
-
False, True
and, or, not, in for logical comparisons
- !=, ==, <, >= for variable comparisons
- Full list can be found online
- Conditional statements perform the same as
most other programming languages
- if, elif, else
Lists
- Extremely powerful variable type in Python
- Declared with a comma separated sequence of
items surrounded by two brackets
- Access an item in the list by index
- Indices start from 0
- .append(), .insert(), .remove(), .index()
- List slicing
- List operators can be found online
Loops
- for and while loops as well as any nested
combination
- range([start], stop[, step]) (More info online)
- “for each” loops (More info online)
for <variable> in <sequence>:
- break, continue, and pass statements
Functions
- def and pass
- Standard parameters
- Default/optional parameters
Advanced Python
- List Comprehension
- Tuples
Features -
-
Dictionaries
Collections
Notebook: https://goo.gl/CtnVph
Python List
- Concise way to create lists
- [ expression for item in list if conditional ]