Explore structured python programming courses, solved problems, simulations and Python activities.
Write a molar mass calculator that reads formulas such as Ca(OH)2, then programs for moles, the limiting reagent, the yield, and the volumes in a dilution or a titration.
Load the elements into a pandas table, sort and filter them, plot the periodic trends, and look for patterns: which properties go together, and which elements break the rule.
Real data is a table with named columns, different types and missing values, and pandas is the library for it. In this course you build tables from dictionaries and read them from CSV text, look at them with shape, dtypes and describe, and find and handle missing values. You choose rows with conditions, labels and places, add new columns with formulas, summarise groups with groupby, and join tables with merge. You draw scatter plots and bar charts straight from a table, and use a log-log graph to find a power law. A project analyses the planets of the Sun, finds Kepler's third law from the data, and predicts a period that was left out of the fit. The practice runs your code and tells you which results are wrong.
Chance is a part of science, and the computer can imitate it. In this course you make random numbers with a seeded generator, so that a simulation can be repeated, and see the law of large numbers. You estimate probabilities and the number pi by the Monte Carlo method, and see that its error falls as one over the square root of the number of trials. You simulate random walks and find that the typical distance grows as the square root of the number of steps, which is diffusion. You simulate radioactive decay and see why small samples are noisy and large samples are smooth. A project asks how sure a measurement is: the standard error, a whole experiment repeated thousands of times, the bootstrap, and the difference between random and systematic errors. The practice runs your code and tells you which results are wrong.
Calculus asks how fast something changes and how much it has added up to. In this course the computer answers both from numbers. You find slopes with the forward and the central difference and with np.gradient, and learn why the best step is not the smallest. You find areas with rectangles and trapezoids, integrate with SciPy, including functions with no antiderivative and infinite limits, and find the work of a changing force. You follow a motion in small steps with Euler's method, see that it is first order, and use solve_ivp. A project follows a ball through the air with drag, stops it at the ground with an event, and finds that the best angle is lower than 45 degrees. The practice runs your code and tells you which results are wrong.
Many equations in science have no formula for their solution. In this course the computer solves them. You find a bracket with a change of sign, write the bisection method, and then Newton's method, which doubles the number of correct digits at every step, and learn when each of them fails. You work with polynomials in NumPy, with polyval, roots and polyfit, fit a straight line to measurements and judge the fit, and solve systems of linear equations with matrices, including a circuit with three unknowns. A project uses brentq and curve_fit from SciPy to fit the decay of a radioactive sample, and finds its half-life with an uncertainty. The practice runs your code and tells you which results are wrong.
A table of numbers hides what a graph shows at once. In this course you draw line graphs with plot, add titles, labels with units, legends and grids, and draw the graph of any formula with linspace. You choose between a line graph, a scatter plot, a bar chart and a histogram, and learn to read each one. You put several graphs in one picture with subplots, add error bars, use a log scale to recognise an exponential decay, and save a graph in a file. A project turns the measured positions of a toy car into the graphs of its speed and acceleration. The practice runs your code and looks at the graphs that you draw.
Science works with many numbers at once. A list can hold them, but it cannot do maths on them. The NumPy array can. In this course you make arrays with array, arange and linspace, write a formula once and use it on a whole array, pick numbers with indexes, slices and boolean masks, and find sums, averages and standard deviations of rows and columns of tables. You learn to be careful with slices, which are views and not copies, and with broadcasting, which lets arrays of different shapes work together. A project finds the best angle for a throw on Earth and on the Moon. The practice runs your code and tells you which results are wrong.
A program that seems to work is not the same as a program that does work. Every programmer writes bugs, and the good ones find them quickly because they have a method. In this course you write tests with assert and with a table of cases, use the unittest module, choose the edge cases that find most bugs, and test with random inputs against a trusted answer. You learn a loop for finding a bug: reproduce it, locate it, explain it, fix one thing, and test again. A small text library with four hidden bugs is the project at the end. The practice runs your code on real cases and tells you which results are wrong.
Lists and dictionaries are not the only ways to organise data. Some jobs fit a pile of things, some a waiting line, some a chain of nodes, some a family tree, and some a map of connections. In this course you use a stack and a queue, build a linked list from nodes, write a binary search tree and walk through it in order, and store a graph as a dictionary of neighbours. You use breadth-first search to find the fewest steps between two places, and depth-first search to find everything that can be reached. A route finder on a small map is the project at the end. The practice runs your code on real cases and tells you which results are wrong.
A for loop that builds a list is so common that Python has a short way to write it. In this course you write list, dictionary and set comprehensions, use the helpers zip, enumerate, any, all and sorted with a key, and see what a for loop really does underneath, with iterables and iterators. You write generators with yield, which give their values one at a time and so can handle very long or even endless sequences, and you join generators into a pipeline. A word-frequency pipeline is the project at the end. The practice runs your code on real data and tells you which results are wrong.
Everything that a program knows disappears when it ends. A file keeps data after the program is gone, and lets one program hand its data to another. In this course you read and write text files with the with statement, choose between the read, write and append modes, handle a missing file with try and except, treat the lines of a file as records, read and write tables in the CSV format, and save whole lists and dictionaries in the JSON format. A marks book that remembers its marks between runs is the project at the end. The practice runs your code on real files and tells you which results are wrong.