Variables &
Data Types
Integers
int
- Whole numbers with no decimal places
Floats
float
- Floating-point numbers
Booleans
bool
- Boolean values (True or False)
Strings
str
- Sequence of Unicode characters
Lists
list
- Mutable sequence of items
Tuples
tuple
- Immutable sequence of items
Dictionaries
dict
- Unordered collection of key-value pairs
Sets
Object-Oriented
Programming
class
: Defining a class
Polymorphism
__call__()
: Calling an object
__getitem__()
,__setitem__()
,__delitem__()
: Item access
Generators
Generator Functions
Generator Expressions
Functional
Programming
Lambda Functions
lambda
: Creating anonymous functions
Map, Filter, Reduce
map()
: Applying a function to each item in an iterablefilter()
: Filtering an iterable based on a functionfunctools.reduce()
: Applying a function of two arguments cumulatively
List Comprehensions, Dict Comprehensions
[expr for item in iterable]
: Creating a list comprehension{key:value for item in iterable}
: Creating a dictionary comprehension
Operators & Control
flow
Python Class
Attributes
When Should You Use Python Class Attributes?:
Python Class Variables vs. Instance Variables:
Python Class Attributes vs. Instance Attributes:
Encapsulation
__getattr__()
, __setattr__()
, __delattr__()
: Attribute access
__str__()
,__repr__()
: String representation
Exception
Handling
try
: Attempting a block of code
raise
: Raising an exception
class
: Defining a custom exception
DSA
Arrays and Linked Lists
Stacks and Queues
Trees and Graphs
Sorting Algorithms
bubble_sort()
,insertion_sort()
,merge_sort()
: Implementing custom sorting algorithms
Searching Algorithms
Functions
File I/O
Inheritance
class
: Defining a derived class
super()
: Accessing the parent class
Abstraction
abc.ABC
, abc.abstractmethod()
: Abstract base classes
Decorators
Function Decorators
@decorator
: Applying a decorator to a functionfunctools.wraps()
: Preserving function metadata
Class Decorators
@decorator
: Applying a decorator to a class