The materials are designed to resemble an interactive book.
The files come primarily in the Jupyter Notebook format (i.e., *.ipynb) but also as modules and packages (i.e., *.py). Together with some other static files (e.g., images), they are stored in one folder per chapter in this repository. They are to be opened from within the JupyterLab application, even though other ways are certainly possible as well. Both the files and the folders are appropriately named with prefixes indicating the order in which they should be read and starting with "00_".
It is recommended to follow the installation instructions in the README.md file and work through the content on one's own computer.
If this is not possible, the files can be viewed in a web browser either statically (i.e., read-only) on nbviewer or interactively (i.e., code can be executed) on Binder .
- Chapter 0: Introduction
- content (Python's History & Background; Open-source & Communities; JupyterLab; Programming vs. Computer Science; Learning Tips)
- exercises (Mastering Markdown)
- review questions
- Part A: Expressing Logic
- Chapter 1: Elements of a Program
- content (A first Example: Averaging Even Numbers; Operators; Objects & Data Types; Errors)
- exercises (Printing Output)
- exercises
(Simple
for
-loops) - content (Memory in Detail; Variables & References; Mutability; Expressions & Statements)
- exercises (Python as a Calculator)
- summary
- review questions
- further resources
- Chapter 2: Functions & Modularization
- content (Built-in Functions & Constructors; Function Definitions; Function Calls & Scoping Rules; Positional vs. Keyword Arguments; Modularization)
- exercises (Volume of a Sphere)
- content
(Standard Library:
math
&random
Modules; Third-party Packages:numpy
Library; Writing one's own Modules) - summary
- review questions
- Chapter 3: Conditionals & Exceptions
- content
(Boolean Expressions;
Relational Operators;
Logical Operators;
if
statement; Exception Handling) - exercises (Discounting Customer Orders)
- exercises (Fizz Buzz)
- summary
- review questions
- content
(Boolean Expressions;
Relational Operators;
Logical Operators;
- Chapter 4: Recursion & Looping
- content (Recursion; Examples: Factorial, Euclid's Algorithm, & Fibonacci; Duck Typing; Type Casting & Checking; Input Validation)
- exercises (Towers of Hanoi)
- content
(Looping with
while
&for
; Examples: Collatz Conjecture, Factorial, Euclid's Algorithm, & Fibonacci; Containers vs. Iterables) - content
(Customizing Loops with
break
andcontinue
; Indefinite Loops) - exercises (Throwing Dice)
- summary
- review questions
- Chapter 1: Elements of a Program
- Part B: Managing Data and Memory
- Chapter 5: Numbers & Bits
- content
(
int
Type; Binary & Hexadecimal Representations; Bit Arithmetic; Bitwise Operators) - content
(
float
Type; Floating-point Standard; Special Values; Imprecision; Binary & Hexadecimal Representations) - content
(
complex
Type; Numerical Tower; Duck vs. Goose Typing) - appendix
(
Decimal
Type;Fraction
Type) - summary
- review questions
- further resources
- content
(
- Chapter 6: Text & Bytes
- content
(
str
Type; Reading Files; Sequences; Indexing & Slicing; String Methods & Operations; String Interpolation) - exercises (Detecting Palindromes)
- content
(Special Characters;
ASCII & Unicode;
Multi-line Strings;
bytes
Type; Character Encodings) - summary
- review questions
- further resources
- content
(
- Chapter 7: Sequential Data
- content
(Collections vs. Sequences;
ABCs:
Container
,Iterable
,Sized
, &Reversible
) - content
(
list
Type; Indexing & Slicing; Shallow vs. Deep Copies; List Methods & Operations) - exercises (Working with Lists)
- content
(Modifiers vs. Pure Functions;
tuple
Type; Packing & Unpacking;*args
in Function Definitions) - exercises (Packing & Unpacking with Functions)
- appendix
(
namedtuple
Type) - summary
- review questions
- content
(Collections vs. Sequences;
ABCs:
- Chapter 8: Map, Filter, & Reduce
- content
(Mapping;
Filtering;
Reducing;
lambda
Expression) - content
(
list
Comprehension;generator
Expression; Streams of Data; Boolean Reducers) - exercises (Removing Outliers in Streaming Data)
- exercises (Packing & Unpacking with Functions, continued)
- content
(Iterators vs. Iterables;
Example:
sorted()
vs.reversed()
) - summary
- review questions
- content
(Mapping;
Filtering;
Reducing;
- Chapter 9: Mappings & Sets
- content
(
dict
Type; Nested Data; Hash Tables;dict
Methods & Behavior;dict
Comprehension) - exercises (Working with Nested Data)
- content
(
**kwargs
in Function Definitions; Memoization) - exercises (Memoization without Side Effects)
- content
(
set
Type;set
Methods & Operations;set
Comprehension;frozenset
Type) - appendix
(
defaultdict
Type;Counter
Type;ChainMap
Type) - summary
- review questions
- further resources
- content
(
- Chapter 10: Arrays & Dataframes
- Chapter 11: Classes & Instances
- content
(
class
Statement; Instantiation; Text Representations; Instance Methods vs. Class Methods; Computed Properties) - exercises (A Traveling Salesman Problem)
- content (Sequence Emulation & Iteration; Python's Data Model; (Im)mutable Data Types; Method Chaining; Polymorphism)
- content (Operator Overloading: Arithmetic & Relational Operators; Number Emulation)
- content
(Writing one's own Packages;
The final
Vector
&Matrix
Classes; Comparison withnumpy
) - summary
- review questions
- content
(
- Chapter 5: Numbers & Bits