🌍 Data Science · subject
Data Science Python Programming Syllabus
The Python Programming syllabus for Data Science in full: 9 chapters, 30 topics and 62 sub-topics, every one listed below, plus 73 Python Programming flashcards with answers.
Python Programming syllabus: all 9 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
-
Data Science
6 topics- NumPy
- Pandas
- SciPy
- Matplotlib
- Seaborn
- Plotly
Data Science Python Programming flashcards — 73 questions with answers
In what year was Python first released, and who created it?
Python was first released in 1991 by Guido van Rossum.
After what was the Python language named?
It was named after the British comedy group Monty Python's Flying Circus, not the snake.
What role did Guido van Rossum hold in the Python community, and what is it called?
He was the BDFL (Benevolent Dictator For Life), the final decision-maker on the language, until he stepped down in 2018.
What are the two major Python versions, and which is current and supported?
Python 2 and Python 3. Python 3 is current; Python 2 reached end-of-life on January 1, 2020, and is no longer supported.
What is 'The Zen of Python' and how do you display it?
It is a collection of 19 guiding aphorisms for writing Python code, displayed by running import this.
What command verifies that Python is installed and shows its version?
python --version (or python3 --version), which prints the installed version number.
What is pip in the Python ecosystem?
pip is Python's standard package installer, used to install and manage third-party packages from PyPI (e.g., pip install requests).
What is a Python virtual environment and what command creates one?
An isolated directory with its own Python interpreter and packages, keeping project dependencies separate. Created with python -m venv myenv.
What is the interactive Python interpreter (REPL)?
REPL stands for Read-Eval-Print Loop; it executes statements one at a time interactively, started by typing python at the command line.
How does Python define code blocks instead of using braces?
Python uses indentation (whitespace), conventionally 4 spaces, to delimit code blocks; consistent indentation is mandatory.
What are the two ways to write comments in Python?
Single-line comments start with #; multi-line text is often written as a triple-quoted string ('''...''' or """...""").
What is the difference between a statement and an expression in Python?
An expression evaluates to a value (e.g., $2 + 3$); a statement performs an action (e.g., an assignment or if-statement) and may not produce a value.
What function outputs text to the console, and what function reads user input?
print() displays output; input() reads a line from the user and always returns it as a string.
List Python's four primitive (basic) data types.
int (integers), float (decimals), str (strings), and bool (booleans True/False).
What is the difference between an int and a float in Python?
int is a whole number of unlimited precision (e.g., 5); float is a floating-point decimal number (e.g., 5.0), stored as a 64-bit double.
What two values does the bool type hold, and what integers do they equal?
True and False; True equals $1$ and False equals $0$ when used numerically.
What is the special type representing 'no value' in Python?
NoneType, whose single value is None, representing the absence of a value.
How do you find the data type of a value in Python?
Use the built-in type() function, e.g., type(5) returns <class 'int'>.
Name the four most common complex (collection) data types in Python.
list, tuple, dict (dictionary), and set.
What is the key difference between a list and a tuple?
A list is mutable (changeable) and uses square brackets []; a tuple is immutable (unchangeable) and uses parentheses ().
Show the other 53 Python Programming flashcards
What is a Python dictionary and how is it written?
A mutable, unordered collection of key-value pairs written with curly braces, e.g., {'name': 'Ann', 'age': 30}; keys must be unique and hashable.
What distinguishes a set from a list in Python?
A set is an unordered collection of unique elements (no duplicates) written with curly braces {} or set(); it does not support indexing.
What is indexing, and what index refers to the first and last element of a sequence?
Indexing accesses an element by position; index 0 is the first element and index -1 is the last element.
What does the slice my_list[1:4] return?
Elements at indices 1, 2, and 3 (the stop index 4 is excluded).
What is the syntax for assigning a variable in Python?
variable_name = value; no type declaration is needed because Python is dynamically typed.
What does multiple assignment a, b = 1, 2 do?
It unpacks values, assigning a = 1 and b = 2 simultaneously (tuple unpacking).
What naming convention is recommended for Python variables?
snake_case (lowercase words separated by underscores); names must start with a letter or underscore and cannot be a reserved keyword.
In Python, what does the variable actually store when you write x = [1, 2, 3]?
It stores a reference (pointer) to the list object in memory, not a copy of the object itself.
What is the augmented assignment operator and give an example?
An operator that combines an operation with assignment, e.g., x += 1 is shorthand for x = x + 1.
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 — each clause ends with a colon and its block is indented.
List Python's six comparison operators.
Equal $==$, not equal $\neq$ (!=), greater than $>$, less than $<$, greater-or-equal $\geq$ (>=), and less-or-equal $\leq$ (<=).
What are Python's three logical operators?
and, or, and not, used to combine or negate boolean expressions.
What is the ternary (conditional) expression syntax in Python?
value_if_true if condition else value_if_false, e.g., 'even' if n % 2 == 0 else 'odd'.
Which values are considered 'falsy' in Python?
None, False, zero ($0$, $0.0$), and empty containers (empty string '', [], {}, (), set()); everything else is truthy.
What is the difference between == and is in Python?
== compares whether two values are equal; is compares whether two references point to the same object in memory (identity).
What are the two main loop types in Python and their typical uses?
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) generate?
The sequence 2, 4, 6, 8 — start at 2, stop before 10, step by 2.
What do the break and continue statements do in a loop?
break exits the loop entirely; continue skips the rest of the current iteration and moves to the next one.
What is the purpose of a loop's else clause in Python?
The else block runs after the loop completes normally (i.e., not terminated by a break).
Write the list comprehension that produces the squares of numbers 0 through 4.
[x**2 for x in range(5)], which yields [0, 1, 4, 9, 16].
What keyword defines a function in Python, and what keyword returns a value?
def defines a function; return sends a value back to the caller (a function with no return returns None).
What is the difference between a positional argument and a keyword argument?
A positional argument is matched by order; a keyword argument is matched by name, e.g., func(x=5).
How do you give a function parameter a default value, and why be careful with mutable defaults?
Write it as def f(x=10):. Avoid mutable defaults like def f(x=[]): because the same list is shared across all calls.
What do *args and **kwargs allow in a function definition?
*args collects extra positional arguments into a tuple; **kwargs collects extra keyword arguments into a dictionary.
What is a lambda function in Python?
An anonymous, single-expression function, e.g., square = lambda x: x**2; it returns the expression's value automatically.
What is variable scope, and what does the LEGB rule stand for?
Scope is the region where a name is accessible. LEGB is the lookup order: Local, Enclosing, Global, Built-in.
What is a Python decorator?
A function that takes another function and extends or modifies its behavior, applied with the @decorator syntax above a function definition.
What is a generator function and which keyword creates one?
A function that yields values lazily one at a time using the yield keyword, producing an iterator instead of returning all results at once.
What is the Python Standard Library?
A large collection of modules and packages bundled with Python (e.g., math, os, sys, random, datetime, json) available without separate installation.
How do you compute $\sqrt{16}$ and access $\pi$ using the standard library?
Import the math module: math.sqrt(16) returns $4.0$, and math.pi returns approximately $3.14159$.
What is the difference between import module and from module import name?
import module brings in the whole module (access via module.name); from module import name brings a specific object directly into the namespace.
What is a Python module?
A single .py file containing Python definitions and statements that can be imported and reused in other programs.
What does the if __name__ == '__main__': idiom do in a module?
It runs the indented code only when the file is executed directly, not when it is imported as a module.
What is a Python package, and what file traditionally marks a directory as one?
A package is a directory of related modules; an __init__.py file traditionally marks the directory as a package (optional since Python 3.3 namespace packages).
What is the difference between an absolute import and a relative import?
An absolute import uses the full path from the project root (import mypackage.module); a relative import uses dots relative to the current package (from . import module).
What is the recommended way to open a file so it closes automatically?
Use a with statement (context manager): with open('file.txt') as f: — the file is closed automatically when the block ends.
What are the file modes 'r', 'w', 'a', and 'r+'?
'r' read (default), 'w' write (truncates/creates), 'a' append (adds to end), and 'r+' read and write.
What is the difference between read(), readline(), and readlines()?
read() returns the entire file as one string; readline() returns the next single line; readlines() returns a list of all lines.
What is the difference between text mode and binary mode when opening a file?
Text mode ('t', default) reads/writes str and handles encoding; binary mode ('b', e.g., 'rb') reads/writes raw bytes without decoding.
What methods write data to a file in Python?
f.write(string) writes a single string, and f.writelines(list) writes a list of strings; neither adds newline characters automatically.
Why might you call f.flush() when writing to a file?
To force buffered data to be written to disk immediately, rather than waiting for the buffer to fill or the file to close.
Which standard library module is the modern, object-oriented way to handle file paths?
pathlib, whose Path class provides cross-platform path manipulation (e.g., Path('data') / 'file.txt').
What does os.path.join('folder', 'file.txt') do and why use it?
It joins path components with the correct OS-specific separator, ensuring code works across Windows and Unix systems.
How do you check whether a file or directory exists using the standard library?
Use os.path.exists(path) or, with pathlib, Path(path).exists().
What is the difference between an absolute path and a relative path?
An absolute path specifies the location from the root of the filesystem; a relative path is specified relative to the current working directory.
What is an exception in Python?
An error detected during execution that disrupts the normal flow of the program; if unhandled, it terminates the program with a traceback.
What is the difference between a syntax error and an exception?
A syntax error is detected before execution when the code cannot be parsed; an exception (runtime error) occurs while the program is running.
What is the base class of (almost) all built-in exceptions in Python?
BaseException, though user-defined and most catchable exceptions inherit from Exception.
Name three common built-in exception types and when they occur.
ValueError (right type, wrong value), TypeError (wrong type), and ZeroDivisionError (division by zero). Others include KeyError, IndexError, and FileNotFoundError.
What is the basic try/except syntax for handling an exception?
try:\n risky_code()\nexcept SomeError:\n handle_it() — code in try is attempted, and except catches the named error.
What is the purpose of the else and finally clauses in a try statement?
else runs if no exception occurred in the try block; finally always runs (cleanup), whether or not an exception was raised.
How do you manually trigger an exception in Python?
Use the raise statement, e.g., raise ValueError('invalid input').
How can you catch an exception and access its error message in the except block?
Use as to bind it, e.g., except ValueError as e:, then use str(e) or print(e) to read the message.
Data Science Python Programming FAQ
What is in the Data Science Python Programming syllabus?
Data Science Python Programming is split into 9 chapters: Introduction to Python, Data Types and Variables, Control Flow, Functions, Modules and Packages, File Handling, Error and Exception Handling, Object-Oriented Programming and Data Science. Together they contain 30 topics and 62 sub-topics.
How many chapters are in Data Science Python Programming?
9 chapters, containing 30 topics and 62 sub-topics. The largest chapter is Data Science, with 6 topics.
Are there flashcards for Data Science Python Programming?
Yes — a 73-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.