
Introduce scientific programming with Python, presenting a nine-chapter foundation, open resources, and a hands-on workflow across VSCode, Anaconda, and notebooks to guide learning.
Learn to write hello world in Python using print in Python 3, and differences from Python 2. Explore running Python via the command line, VS Code, and Anaconda.
Explore the different ways of using Python, including text editors, IDEs, terminals, IPython, Spyder, Idle, and notebooks, and compare Python 2 and Python 3 print syntax for practical scientific programming.
Translate a simple mathematical formula into Python to compute interest. Build a Python program using variables, comments, and syntax to calculate final amount from principal, rate, and years.
Define variables as containers, demonstrate assignment and printing, compare assignment versus equality, and illustrate using descriptive names with integers and floats for principal, rate, years, and comments.
Explore comments and variable types in Python, including int, float, string, and basic data types; learn type conversion with int, float, and str, plus local and global scope.
Learn to format text output in Python using print statements and f-strings, embedding variables in curly braces with format specifiers to control decimals, integers, and compact representations.
Explore how importing modules expands Python's capabilities, from math to numpy and matplotlib, and compare three import methods: import module, from module import function, and from module import everything.
Learn how rounding errors and inexact arithmetic affect Python math, see why 1/49 and 1/51 differ, and apply tolerance when comparing floats; avoid reserved words and integer-division pitfalls.
Learn how Python loops and lists relate, exploring while, do-while, and for loops to automate repetitive tasks, using indentation, conditions, and lists to drive iterations.
Learn boolean expressions in Python, distinguishing assignment from equality with the double equal sign, and using comparison operators and not, and/or to drive while and for loops.
Learn how Python lists store sequences of data using square brackets, access elements by index (0-based indexing), and use append, extend, and nested lists to manage heterogeneous data.
Explore iterating over a list in Python with a for loop, compare it to a while loop, and see how range, in, and printing the result drive the task.
Explains how to use range with start, stop, and step to iterate over lists, build sequences with for loops, and compute a sum of squares.
Learn to replace list elements in Python via index with a for loop using range(len(v)) and v[i] += 2, avoiding value iteration; and preview list comprehensions for compact list creation.
Compare for loops with list comprehensions in Python to create lists compactly, using range and append versus the single-line syntax. Learn to build multiple lists and traverse them with zip.
Explore how zip pairs elements from two lists into tuples, enabling simultaneous traversal with a for loop. Compare zip with range for printing low and high values.
Explore nested lists in Python, including how to create, access, slice, and modify multi-level lists with indexing, negative indexing, and common methods like append and pop.
Master list slicing in Python by selecting sublists, including nested lists, with start, end, and step; explore negative indices, reverse slices, and using slicing for insertion, replacement, and removal.
Define and use functions with def in python, manage parameters and docstrings, and implement if statements for branching to solve equations and create reusable code.
define function arguments and distinguish positional from keyword arguments. explain positional arguments assigned by position and keyword arguments matched by name, and relate local and global variables.
Compare local and global variables in Python functions, and observe how locals are limited to their function while globals are accessible project-wide. Learn precedence and using the global namespace.
Explore how a Python function returns multiple values as a tuple, unpacking results into position and velocity, and compare tuple versus list behavior to protect data from unintended changes.
Explore a Python function that computes a sum approximation for minus log one minus x with finite n, compares it to the actual value, and examine return versus no-return behavior.
Explore default function arguments and keyword arguments in Python, learn to add docstrings, and apply a velocity-time example to override defaults for flexible calculations.
Learn how to document Python functions with docstrings using triple quotes, capturing a function's purpose, arguments, and return value, improving readability and future usability.
Explore branching the program flow with if tests in Python, covering boolean expressions, else and else-if structures, and inline one-line forms with practical examples.
Explore passing functions as arguments to other functions and defining lambda expressions for single-line functions. See how a diff tool uses f, x, and h to approximate derivatives.
Learn to implement the bisection method in Python to solve equations by checking a sign change of f(a) and f(b), iterating with midpoints until tolerance, and testing edge cases.
Explore Newton's method for solving equations using local linearization to update x with x_{n+1}=x_n - f(x_n)/f'(x_n); compare fast convergence to bisection and note tolerance and iteration limits on f(x)=x^2-4x+e^{-x}.
Learn to write a test function to verify Python programs, covering unit tests, integration tests, and test driven development. Use assert to compare expected and actual results in simple examples.
Create test functions with multiple scenarios using the py test library to verify programs, employing assert with a tolerance, and adopt test_ prefixes for automated testing.
Develop interactive Python programs by obtaining user input with the input function, converting types, and handling errors, then explore command line and file input for flexible data entry.
Learn to read user input with Python command line arguments using sys.argv. Discover passing arguments to a program from Unix, Windows, or PowerShell and running as a script.
Explore flexible user input in Python using eval and exec to infer types from strings, lists, and tuples, while comparing safety and reliability with explicit type conversion.
Learn to handle flexible user input using exec and eval in Python. The lecture contrasts evaluating expressions with executing statements, handles multi-line strings, and builds an input-driven calculator.
Learn to read data from files in Python using open, with blocks, and try/except, then parse lines, split data, and compute a mean from a sample rainfall dataset.
Learn to write data to files in Python by opening a file in write mode, writing strings or lists, and closing the file or using a with open context.
Explore handling errors in Python using standard exceptions and try-except blocks, with hands-on demos of input validation, command-line arguments, and common errors like index, value, and syntax errors.
Learn to handle Python errors using try/except, else, and finally, and raise custom exceptions with tailored messages. Explore using index and value errors to guide users and validate input.
Learn how to create reusable Python modules by defining functions in a file, saving it, and importing it with import or from, then test and reuse them across projects.
Explore numpy and array computing for scientific programming, including vector generalization, storage of xy points in two- or three-dimensional space, lists versus numpy arrays, and plotting curves with matplotlib.
Store and plot xy points on a curve using numpy arrays versus Python lists, demonstrating vectorized computation with np.zeros, linspace, and array operations.
Learn to plot curves with matplotlib in Python, build a basic chart, and configure titles, legends, and axis labels while plotting multiple curves.
Learn to create and refine matplotlib plots by adding labels, legends, axis ranges, and titles, plot multiple curves from custom functions, and export figures in several formats.
Learn to plot discontinuous, piecewise-defined functions in Python using a simple h(x) test with values like -5 and 10, and compare for loops, vectorization, and numpy where in plotting.
Learn to turn static plots into animations using matplotlib and numpy, export frames for a movie, or use matplotlib's built-in animation to visualize a gaussian bell function.
The second alternative saves each plot frame as a distinct image on disk and uses tools like ImageMagick or ffmpeg to assemble a movie, detailing frame counting and file naming.
Explore three methods to animate a matplotlib plot, then implement the third using FuncAnimation, updating the plot across frames and exporting to mp4 from a frame sequence.
Explore advanced numpy array operations, including creating zeros to match another array, array copying, converting lists with asarray, slicing, boolean indexing, and multi-dimensional assignments for efficient vectorized computing and plotting.
Learn how Python dictionaries map keys to values using curly braces, and compare them with lists while adding and accessing key-value pairs.
Discover the similarities between dictionaries and lists in python, focusing on keys, values, membership testing, and deletion. Understand copy behavior—reference versus clone—and how to print keys and values efficiently.
Learn to represent polynomials with a dictionary, using power as the key and coefficient as the value, and compare it to a list representation while evaluating polynomials.
Learn to read text data from a file into a dictionary, using the first column as the key and the second as the value, with cleaning and float conversion.
Explore string manipulation in Python by performing slicing, find and replace, and split and join operations, with practical code demonstrations.
Learn how string splitting and joining act as inverse operations, with code demonstrating split and join, and explore immutable strings and replacement techniques.
Explore common python string methods, including strip, split, capitalize, and isdigit, and learn to read, parse, and convert lines into (x, y) numeric pairs.
Learn the basics of Python classes, including defining a class, using initialization (the constructor) and self, creating instances, and encapsulating data and methods for parametric calculations.
Explore how to protect class attributes in Python by marking them as protected with a leading underscore, illustrated through a bank account example and guarded access via methods.
Explore Python special methods, including __call__ and __str__, and see how constructors (__init__) create instances and enable callable objects and custom print outputs.
Explore Python special methods for arithmetic operations and __repr__ representations, and learn to inspect class content with __dict__ and __module__.
Explore automatic differentiation of functions by implementing a derivative class that computes d/dx via finite differences, using f(x), h, and examples like x^2 and sine.
Learn how to test class functions by creating instances and verifying methods against known outputs. Use a linear function ax + b and a lambda input to validate derivatives.
Build a polynomial class in Python that stores coefficients with dictionaries or lists and supports addition, multiplication, differentiation, printing, and testing with sample polynomials.
Explore class hierarchy and inheritance in Python, including single, multiple, and hierarchical inheritance, and see how subclasses reuse attributes and methods from parent classes with minimal duplication.
Explore numerical differentiation using forward, backward, and central difference formulas implemented as a Python class hierarchy, applying to the sample function exp(-x) sin(4 pi x) and comparing accuracy.
Explore 9.3 example: numerical integration with Python classes, implementing trapezoidal, midpoint, and Simpson methods, using a superclass and subclass design to vectorize the integrate method.
This book "Scientific Programming with Python" teaches the Python programming language, which is one of the most popular languages for introductory programming courses. An advantage of Python is that it is a so-called high-level language, with simple and intuitive syntax that makes it easy to get started. However, although it works well as a beginner’s language, Python is also suitable for more advanced tasks, and it is currently one of the most widely used programming languages worldwide.
This course base on this nice book, putting all of the knowledge points together, and making the detail step-by-step live demo to show you the practical approach of learning Python programming language.
The source code (both native Python code and Jupyter notebooks format) are hosted in my GitHub repository (called "python", then you can find the folder "sci-prog" from the README file), you can pick up to start from any point or learn from start.
Python is one very popular and suitable language for learning to program, there's no specific pre-requisite for you to learn in this course, and during the journey, I'd hope you can also compare Python with other hands-on programming language (C, C++, Java, etc..) if you also have touch-based, with those benchmarking you may get deeper understanding of Python programming language's syntax, grammar as well as coding styles.
This course can be used on the foundation for you to explore more topics on Python, I also have some other courses teaching on Python with GUI, Python with Office, Use Python in Math, and also specific library Manim for creating pretty animation, there're big potential of using Python to deal with the situations that you may face and master this language will enable you to solve a problem in structural and computerized manner.
Enjoy your learning, and remember: Learning is a journey, not destination!