Back to Course
Python Essentials: The Engineering Approach
Module 16 of 20
16. The Cheatsheet
Environment
bashpython3 -m venv venv # Create Venv source venv/bin/activate # Activate pip install -r requirements.txt
Types
pythonl = [1, 2] # List (Mutable) t = (1, 2) # Tuple (Immutable) s = {1, 2} # Set (Unique) d = {'k': 'v'} # Dict (Hash Map)
Comprehensions
python[x for x in list] {k:v for k,v in dict.items()}
Classes
pythonclass MyClass(Parent): def __init__(self): super().__init__()
File I/O
pythonwith open('f.txt', 'r') as f: data = f.read()