< All Topics

Python

By reading these notes, you will gain knowledge tailored to your role, whether you are a beginner or practitioner focusing on Python Programming foundations.

Note – This page contains a complete summary of the topics. To learn more about each topic, click on the (Expand)Topic-HeadingImage, or ‘Click Here’ hyperlink.

Before reading this document, please read Programming Basics & Foundations

Python is high level, interpreted, object oriented, high-level programming language with dynamic semantics. It is used everywhere: Scripting, Application development, websites to Artificial Intelligence and Data Science.

11 Python Foundation

TopicKey ConceptsNotesOfficial Documentation Link
Python BasicsVariables,
Memory,
Data Types
Variables: – A name given to a memory location to store data (x = 10).
Memory: – Variables are tags pointing to objects in memory.
Data Types:str (Text), int (Number), float (Decimal), bool (True/False).
Python Tutorial
OperatorsArithmetic, Logical, Comparison// is floor division (drops decimal).
** is power ($2^3$).
is compares memory identity, == compares value.
Code: if x > 5 and y < 10:
Operators
Control FlowConditionals, Loops• Indentation is mandatory.
range(start, stop, step).
break exits loop; continue skips to next iteration.
Code: for i in range(5): print(i)
Control Flow
Strings (Advanced)Slicing, f-strings, Methods• Strings are immutable.
Slicing: text[start:stop:step]text[::-1] reverses string.
f-string: f"Hello {name}" is faster/cleaner.
strip(), split(), join().
String Methods
Data Structures 1Lists & TuplesList: Mutable []. methods: append, pop, sort.
Tuple: Immutable (). Faster, keys for dicts.
Code: my_list = [1, 2, 3]; my_tuple = (1, 2)
Data Structures
Data Structures 2Dictionaries & SetsDict: Key-Value {k:v}. O(1) lookup speed.
Set: Unique items {1, 2}. Great for removing duplicates.
Code: data.get("key", "default_val") avoids errors.
Dictionaries

2. Functional and Modular Programming

TopicKey ConceptsNotesOfficial Documentation Link
FunctionsScope, Return, Argsdef keyword.
*args: Tuple of unknown args.
**kwargs: Dict of unknown keyword args.
Docstrings: """Description""" for documentation.
Code: def add(*nums): return sum(nums)
Defining Functions
Functional ToolsLambda, Map, FilterLambda: One-line anonymous function.
Map: Apply function to all items.
Filter: Select items based on condition.
Code: squares = list(map(lambda x: x**2, numbers))
Functional HOWTO
ComprehensionsList/Dict Comprehension• Pythonic way to create lists.
• More readable than for loops for simple logic.
Code: [x for x in range(10) if x % 2 == 0]
Comprehensions
Modules & PackagesImports, __name__Module: A .py file.
Package: A folder with __init__.py.
if __name__ == "__main__": ensures code runs only when executed directly, not when imported.
Modules
Virtual EnvironmentsIsolation, Dependency MgmtCrucial for every project.
• Prevents library version conflicts.
Cmds: python -m venv venv, source venv/bin/activate (Linux), pip install -r requirements.txt.
venv

3. Object Oriented Programming Python (OOP)

TopicKey ConceptsNotesOfficial Documentation Link
Classes & ObjectsBasics, selfClass: Blueprint. Object: Instance.
self: Reference to the current instance.
__init__: Constructor method.
Code: class Dog: def __init__(self, name): self.name = name
Classes
InheritanceParent/Child, super()• Don’t repeat code. Child inherits Parent’s methods.
super().__init__() calls parent constructor.
Polymorphism: Different classes, same method name.
Inheritance
Magic MethodsDunder Methods• Methods starting/ending with __.
__str__: User-friendly string representation.
__repr__: Developer debugging representation.
__len__, __add__.
Data Model
Advanced OOPDecorators, Properties@property: Access methods like attributes (Getters).
@staticmethod: Function inside class not using self.
@classmethod: Uses cls (affects class state).
Built-in Functions

4. Advanced Concepts

TopicKey ConceptsNotesOfficial Documentation Link
Error HandlingTry, Except, Finally• Never use bare except:. Catch specific errors.
finally: Runs cleanup code (closing files) always.
raise: Trigger custom errors.
Code: try: x/0 except ZeroDivisionError: print("Error")
Errors
File HandlingRead/Write, Context MgrAlways use with open(...) to auto-close files.
• Modes: 'r' (read), 'w' (write/overwrite), 'a' (append).
• Handling CSV and JSON is vital for data exchange.
Input/Output
Iterators & Generatorsyield, Memory EfficiencyGenerator: Returns an iterator, pauses execution with yield.
• Extremely memory efficient for large datasets.
Code: def gen(): yield 1; yield 2
Generators
DecoratorsWrappers, @syntax• Functions that modify other functions without changing their code.
• Used for logging, authentication, timing.
Code: @login_required before a function definition.
Decorators
ConcurrencyThreading vs AsyncIOThreading: I/O bound tasks (network calls).
Multiprocessing: CPU bound tasks (calculations).
AsyncIO: Modern async/await for high-performance I/O.
Code: async def main(): await func()
AsyncIO

5. Libraries and Applications

TopicKey ConceptsNotesOfficial Documentation Link
Standard Libraryos, sys, datetimeos: File paths, env variables (os.getenv).
sys: System arguments (sys.argv).
datetime: Date manipulation (datetime.now()).
Std Lib
RegexPattern Matchingre module.
• Find patterns (emails, phone numbers) in text.
\d (digit), \w (word char), + (one or more).
Regex
Web DevelopmentFlask/FastAPIFlask: Micro-framework, easy for beginners.
Django: Full-stack, “batteries included”.
FastAPI: Modern, fast, for building APIs.
Flask
Data SciencePandas, NumPyNumPy: Math & Matrix calculations.
Pandas: DataFrames (Excel for Python).
Matplotlib: Graphing & plotting.
Pandas

6. Professional Skills

TopicKey ConceptsNotesOfficial Documentation Link
Logginglogging vs printNEW TOPIC
print is for console; logging is for production.
• Levels: DEBUG, INFO, WARNING, ERROR, CRITICAL.
• Can save logs to file with timestamps.
Logging HOWTO
API Interactionrequests, JSONNEW TOPIC
• Interacting with REST APIs.
r = requests.get(url).
data = r.json(). handling status codes (200, 404).
Requests Lib
Database BasicsSQL, SQLiteNEW TOPIC
• Storing data permanently.
• Python has built-in sqlite3.
• Basic syntax: SELECT, INSERT, CURSOR.
SQLite3
TestingUnit Tests, TDDunittest (built-in) or pytest (popular external).
• Writing assertions to verify code works.
assert sum([1,2]) == 3.
Unittest
Security Best PracticesSafety, ValidationNEW TOPIC (For DevSecOps)
• Never use eval() or exec() on user input.
• Use secrets module instead of random for passwords.
• SQL Injection prevention (use parameterized queries).
Security Guide
Code QualityPEP8, LintingNEW TOPIC
• Style guide for Python Code.
• Tools: flake8, black (formatter), mypy (type checking).
Type Hints: def add(x: int) -> int:
PEP 8

Contents
Scroll to Top