Toggle Navigation
Everything
Blog posts
Pages
Home
About
The Author
The Book
This Website
Book
Chapter 1: Introduction
Chapter 2: The Core Python Language I
Examples
Questions
Problems
Additional Problems
Chapter 3: Simple Plotting with pylab
Examples
Problems
Chapter 4: The core Python language II
Examples
Questions
Problems
Additional Problems
Chapter 5: IPython and IPython Notebook
Examples
Chapter 6: NumPy
Examples
Questions
Problems
Additional Examples
Additional Problems
Chapter 7: Matplotlib
Examples
Questions
Problems
Chapter 8: SciPy
Examples
Questions
Problems
Additional Examples
Additional Problems
Chapter 9: General Scientific Programming
Examples
Questions
Problems
Errata
Book (2nd ed.)
Chapter 1: Introduction
Chapter 2: The Core Python Language I
Examples
Questions
Problems
Additional Problems
Chapter 3: Simple Plots and Charts
Examples
Problems
Chapter 4: The core Python language II
Examples
Questions
Problems
Additional Problems
Chapter 5: IPython and Jupyter Notebook
Examples
Problems
Chapter 6: NumPy
Examples
Questions
Problems
Additional Examples
Additional Problems
Chapter 7: Matplotlib
Examples
Questions
Problems
Chapter 8: SciPy
Examples
Questions
Problems
Additional Examples
Additional Problems
Chapter 9: Data Analysis with pandas
Examples
Problems
Chapter 10: General Scientific Programming
Examples
Questions
Problems
Errata
Additional Notes
Blog
Apps
Contact
Home
Book
Chapter 4: The core Python language II
Examples
Examples
E4.1 Assignment vs. the comparison operator
E4.2 Exception tracebacks
E4.3 String representation of vectors
E4.4 Vector cross product
E4.5 try ... except ... else ... finally
E4.6 A simple dictionary of Roman numerals
E4.7 A simple database of astronomical objects
E4.8 Mersenne primes
E4.9 The matrix transpose by list comprehension
E4.10 lambda functions
E4.11 Sorting methods
E4.12 Triangular numbers
E4.13 Issuing a usage method
E4.14 Batch renaming of files
E4.15 The Monty Hall problem
E4.16 A simple Python class
E4.17 The random-flight polymer