🌍 Python · subject
Python Python Programming Syllabus
The Python Programming syllabus for Python in full: 12 chapters, 37 topics and 91 sub-topics, every one listed below, plus 63 Python Programming flashcards with answers.
Python Programming syllabus: all 12 chapters
Expand any chapter to see its topics and sub-topics.
-
Introduction to Python
3 topics- History of Python
- Guido van Rossum
- Python 2 vs Python 3
- Installation
- Downloading Python
- Setting up the Environment
- Using IDEs and Text Editors
- Basic Syntax
- Hello World Program
- Indentation
- Comments
- History of Python
-
Data Types and Variables
3 topics- Primitive Data Types
- Integers
- Floats
- Strings
- Booleans
- Complex Data Types
- Lists
- Tuples
- Dictionaries
- Sets
- Variable Assignment
- Dynamic Typing
- Multiple Assignment
- Variable Scope
- Primitive Data Types
-
Control Flow
2 topics- Conditional Statements
- if Statements
- else Statements
- elif Statements
- Nested Conditions
- Loops
- for Loops
- while Loops
- Nested Loops
- Loop Control Statements
- Conditional Statements
-
Functions
2 topics- Defining Functions
- Function Syntax
- Parameters and Arguments
- Return Values
- Advanced Function Concepts
- Lambda Functions
- Recursive Functions
- Decorators
- Defining Functions
-
Modules and Packages
3 topics- Standard Library
- Importing Modules
- Commonly Used Modules
- Creating Modules
- Writing a Module
- Importing from a Module
- Packages
- Creating a Package
- Using __init__.py
- Standard Library
-
File Handling
3 topics- Reading Files
- Open Function
- Read Methods
- Writing Files
- Write Methods
- Append Methods
- Working with File Paths
- os Module
- Pathlib Module
- Reading Files
-
Error and Exception Handling
3 topics- Understanding Exceptions
- Common Exceptions
- Exception Hierarchy
- Handling Exceptions
- try and except
- else and finally
- Raising Exceptions
- Using raise
- Custom Exceptions
- Understanding Exceptions
-
Object-Oriented Programming
5 topics- Classes and Objects
- Defining Classes
- Creating Objects
- Class Attributes and Methods
- Instance Attributes
- Class Attributes
- Methods
- Inheritance
- Base and Derived Classes
- Method Overriding
- Polymorphism
- Polymorphic Methods
- Operator Overloading
- Encapsulation
- Private and Protected Members
- Getters and Setters
- Classes and Objects
-
Advanced sub-topics
4 topics- Iterators and Generators
- Understanding Iterators
- Creating Generators
- Decorators
- Function Decorators
- Class Decorators
- Context Managers
- Using with Statement
- Creating Custom Context Managers
- Multithreading and Multiprocessing
- Threading Module
- Multiprocessing Module
- Iterators and Generators
-
Web Development
2 topics- Flask
- Setting up Flask
- Routing
- Templates
- Django
- Setting up Django
- Models
- Views
- Templates
- Flask
-
Data Science
4 topics- NumPy
- Arrays
- Operations on Arrays
- Pandas
- DataFrames
- Data Manipulation
- Matplotlib
- Plotting
- Customization
- Scikit-Learn
- Machine Learning Models
- Model Evaluation
- NumPy
-
Testing
3 topics- Unit Testing
- unittest Module
- Writing Test Cases
- PyTest
- Setting up PyTest
- Writing Tests with PyTest
- Mocking
- Using unittest.mock
- Mocking Objects and Methods
- Unit Testing
Python Python Programming flashcards — 63 questions with answers
Who created the Python programming language, and in what year was it first released?
Guido van Rossum created Python; it was first released in 1991.
What was Python named after, and what design philosophy does it emphasize?
Python is named after the British comedy group Monty Python (not the snake). It emphasizes code readability and simplicity, using significant indentation.
What is 'The Zen of Python' and how can you display it?
It is a collection of 19 guiding aphorisms for writing Python code (e.g., 'Readability counts', 'There should be one obvious way to do it'). You display it by running import this.
What major version succeeded Python 2, and when did Python 2 reach end-of-life?
Python 3 (first released in 2008) succeeded Python 2. Python 2 reached end-of-life on January 1, 2020.
Is Python a compiled or interpreted language, and is it statically or dynamically typed?
Python is an interpreted, dynamically typed language. Code is compiled to bytecode and run by the Python interpreter (CPython); variable types are determined at runtime.
What command-line command checks the installed Python version?
python --version or python -V (often python3 --version on macOS/Linux).
What is pip, and what command installs a package called 'requests'?
pip is Python's package installer (Package Installer for Python). Install with: pip install requests.
What is a Python virtual environment, and how do you create one using the built-in module?
A virtual environment is an isolated directory with its own Python and packages, preventing dependency conflicts. Create one with: python -m venv myenv.
What is the standard file extension for a Python source file?
The .py extension.
How does Python define code blocks, and what is the conventional indentation amount?
Python uses indentation (whitespace) to define code blocks rather than braces. The convention (PEP 8) is 4 spaces per indentation level.
How do you write a single-line comment in Python, and how are multi-line strings often used as comments?
A single-line comment starts with #. Triple-quoted strings (''' ''' or """ """) are used for docstrings and sometimes as multi-line comment blocks.
What is PEP 8?
PEP 8 is the official style guide for Python code, defining conventions for naming, indentation, line length, whitespace, and overall readability.
List the four primitive (basic) data types in Python.
int (integers), float (floating-point numbers), str (strings), and bool (booleans True/False).
In Python, what is the result and type of $7 / 2$ versus $7 // 2$?
$7 / 2 = 3.5$ (true division, returns a float). $7 // 2 = 3$ (floor division, returns an int).
What operators give the remainder and exponentiation in Python, and what is $2 ** 5$?
% gives the remainder (modulo) and ** gives exponentiation. $2 ** 5 = 32$.
What are the two boolean values in Python, and which integers do they equal?
True and False (capitalized). True equals 1 and False equals 0 when used numerically.
What does the bool() of an empty container, 0, and None evaluate to? Name Python's 'falsy' values.
They evaluate to False. Falsy values include: False, 0, 0.0, '' (empty string), [] (empty list), {} (empty dict), () (empty tuple), set(), and None. All other values are truthy.
Name the four main complex (collection) data types in Python and their bracket syntax.
list [ ], tuple ( ), dict { key: value }, and set { } (created with set() or {1,2,3}).
What is the key difference between a list and a tuple in Python?
A list is mutable (can be changed after creation) and uses [ ]. A tuple is immutable (cannot be changed) and uses ( ).
What characterizes a Python dictionary, and how do you access a value?
A dictionary is an unordered (insertion-ordered since 3.7) collection of key-value pairs with unique keys. Access a value with my_dict[key] or my_dict.get(key).
Show the other 43 Python Programming flashcards
What are the defining properties of a Python set?
A set is an unordered collection of unique (no duplicates) hashable elements. It supports mathematical operations like union (|), intersection (&), and difference (-).
Are Python strings mutable or immutable, and what does indexing 'Python'[0] return?
Strings are immutable. 'Python'[0] returns 'P' (indexing starts at 0).
What is slicing, and what does the slice s[1:4] return for s = 'Python'?
Slicing extracts a substring/subsequence using s[start:stop:step], where stop is exclusive. s[1:4] returns 'yth'.
How does variable assignment work in Python — are variables typed?
Variables are created by assignment (e.g., x = 5) and are untyped references (names) bound to objects. The same variable can be reassigned to a value of any type at any time.
How do you assign multiple variables at once and swap two values in Python?
Multiple assignment: a, b, c = 1, 2, 3. Swap: a, b = b, a.
What is the difference between == and is in Python?
== tests value equality (do the objects have the same value). is tests identity (do two names refer to the exact same object in memory).
What is the basic syntax of an if/elif/else statement in Python?
if condition:\n block\nelif other_condition:\n block\nelse:\n block\nEach branch's body is indented; conditions evaluate to truthy/falsy values.
What is the ternary (conditional) expression syntax in Python?
value_if_true if condition else value_if_false. Example: status = 'pass' if score >= 50 else 'fail'.
Name the three logical operators in Python and what they do.
and (True if both operands true), or (True if at least one true), and not (negates a boolean). and/or use short-circuit evaluation.
What are the two main loop types in Python and when is each used?
The for loop iterates over a sequence/iterable. The while loop repeats as long as a condition remains True.
What does range(2, 10, 2) produce when iterated?
The values 2, 4, 6, 8 (start=2 inclusive, stop=10 exclusive, step=2).
What do the break and continue statements do inside a loop?
break exits the loop immediately. continue skips the rest of the current iteration and proceeds to the next iteration.
What is the purpose of an else clause attached to a Python loop?
The loop's else block runs only if the loop completes normally without hitting a break statement.
What is enumerate() used for in a for loop?
enumerate(iterable) yields pairs of (index, item), letting you access both the position and value: for i, item in enumerate(my_list).
How do you define a function in Python, and what keyword returns a value?
Use the def keyword: def my_func(params):. The return keyword sends a value back to the caller (a function with no return returns None).
What is the difference between positional arguments and keyword arguments?
Positional arguments are matched by their order/position. Keyword arguments are passed by name (e.g., func(x=5)), so order does not matter.
How do you give a function parameter a default value, and what is a caveat?
def f(x, y=10): assigns 10 as the default for y. Caveat: mutable default arguments (like []) are created once and shared across calls; use None as the default instead.
What do *args and **kwargs mean in a function definition?
*args collects extra positional arguments into a tuple. **kwargs collects extra keyword arguments into a dictionary, allowing variable numbers of arguments.
What is a lambda function in Python?
A lambda is a small anonymous function defined inline: lambda args: expression. Example: square = lambda x: x ** 2.
What is a Python docstring and how do you access it?
A docstring is a string literal as the first statement in a function, class, or module, used for documentation. Access it via the object's __doc__ attribute or help(object).
Explain variable scope in Python and the LEGB rule.
LEGB defines name lookup order: Local, Enclosing (nested function), Global (module), Built-in. Python searches these scopes in that order to resolve a name.
What do the global and nonlocal keywords do?
global lets a function rebind a module-level variable. nonlocal lets a nested function rebind a variable in the nearest enclosing (non-global) function scope.
What is a decorator in Python?
A decorator is a function that takes another function and extends/modifies its behavior without changing its code, applied with @decorator_name syntax above a function definition.
What is the Python Standard Library?
A large collection of modules and packages bundled with Python (e.g., math, os, sys, random, datetime, json) providing common functionality without separate installation ('batteries included').
Which standard library module provides mathematical functions, and what does math.sqrt(16) return?
The math module. math.sqrt(16) returns $4.0$ (a float).
What is a Python module, and how do you create one?
A module is a single .py file containing Python definitions and statements. You create one simply by saving code in a file (e.g., mymodule.py) and importing it with import mymodule.
What are three ways to import from a module?
1) import module (then module.name). 2) from module import name (direct access to name). 3) import module as alias (e.g., import numpy as np).
What is the purpose of the if __name__ == '__main__': block?
It contains code that runs only when the file is executed directly as a script, not when it is imported as a module (because __name__ equals '__main__' only for the directly-run file).
What is a Python package, and what file traditionally marks a directory as one?
A package is a directory containing multiple modules, organizing them into a namespace hierarchy. An __init__.py file traditionally marks a directory as a package.
What is the standard built-in function to open a file, and what is the recommended way to ensure it closes?
open(filename, mode) opens a file. Use a with statement (context manager): with open('f.txt') as file: — it automatically closes the file even if an error occurs.
What file modes are used for reading, writing (overwrite), and appending?
'r' = read (default), 'w' = write (creates/truncates/overwrites), 'a' = append (adds to end). Add 'b' for binary (e.g., 'rb') and '+' for read-and-write.
What is the difference between file.read(), file.readline(), and file.readlines()?
read() returns the entire file as one string; readline() returns the next single line; readlines() returns a list of all lines.
How do you write text to a file, and does write() add a newline automatically?
Use file.write(text) (or file.writelines(list)). write() does NOT add a newline automatically — you must include \n yourself.
Why is the os.path / pathlib approach preferred over hardcoding file paths with slashes?
They build OS-independent paths. os.path.join() and pathlib.Path use the correct separator for each operating system (/ on Unix, \\ on Windows), avoiding cross-platform bugs.
What modern module/class provides object-oriented file path handling, and how do you join paths with it?
The pathlib module's Path class. Join paths with the / operator: Path('folder') / 'file.txt'.
What is an exception in Python?
An exception is an error detected during execution that disrupts the normal flow of the program. If unhandled, it propagates up and terminates the program with a traceback.
What is the difference between a syntax error and an exception?
A syntax error occurs at parse time before the program runs (invalid code structure). An exception occurs at runtime during execution of otherwise syntactically valid code.
Name common built-in exceptions for: wrong type, bad value, missing dict key, and division by zero.
TypeError (wrong type), ValueError (right type but invalid value), KeyError (missing dictionary key), and ZeroDivisionError (dividing by zero).
What is the basic try/except syntax for handling an exception?
try:\n risky_code()\nexcept SomeError as e:\n handle(e)\nThe except block runs only if a matching exception is raised in the try block.
What is the purpose of the else and finally clauses in a try statement?
else runs only if the try block raised no exception. finally always runs (whether or not an exception occurred), typically for cleanup like closing resources.
How do you manually trigger an exception in Python?
Use the raise statement, e.g., raise ValueError('invalid input'). You can raise built-in or custom exceptions.
How do you create a custom exception class in Python?
Define a class that inherits from Exception (or a subclass): class MyError(Exception): pass. Then raise it with raise MyError('message').
How can you catch multiple different exception types in Python?
Use multiple except blocks, or group types in a tuple: except (TypeError, ValueError) as e:. Order matters — more specific exceptions should come before general ones.
Python Python Programming FAQ
What is in the Python Python Programming syllabus?
Python Python Programming is split into 12 chapters: Introduction to Python, Data Types and Variables, Control Flow, Functions, Modules and Packages, File Handling, Error and Exception Handling, Object-Oriented Programming, Advanced sub-topics, Web Development, Data Science and Testing. Together they contain 37 topics and 91 sub-topics.
How many chapters are in Python Python Programming?
12 chapters, containing 37 topics and 91 sub-topics. The largest chapter is Object-Oriented Programming, with 5 topics.
Are there flashcards for Python Python Programming?
Yes — a 63-card Python Programming deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.