Interactive, runnable Python. Edit the code, run it in your browser, no setup required.
You will write the reader at the heart of a molar mass calculator. It turns a formula string into a dictionary of symbols and counts, then a second function opens one bracket. The idea. re.findall(r"([A-Z][a-z]?)(\d*)…
Ammonia burns in oxygen in the first step of making nitric acid: 4NH_3 + 5O_2 → 4NO + 6H_2O. You will write a function that takes the moles of the reactants and returns the limiting reagent, the moles of each product…
You will ask the table of the first 20 elements three questions: which elements are alkali metals, how period 3 lines up by size, and what each ionisation enthalpy is in electron volts. The idea. A filter is df[condit…
You will find, with pandas alone, the elements of periods 2 and 3 whose first ionisation enthalpy falls below the element before, and the mean of each block. The idea. df.groupby("period")["ie"].diff() gives the chang…
Make a table from lists and ask it a question. The checker looks at the columns, the shape and the answer.
Clean a table and pick rows from it. The checker uses a small table with missing values.
Add a column with Kepler's ratio, and a group mean. The checker tests that the given table does not change.
Join two tables and count the groups. The checker uses small tables with a key in common.
Draw a log-log graph from a table, and find its power. The checker looks at the axes of your graph and at the number.
Write the analysis of the project as two functions. The checker uses exact data of a law with the power 1.5, with one missing value.
Write two small functions for the rolls of a die. The checker tests that the rolls are reproducible, that they are whole numbers from 1 to 6, and that the mean is right.
Write two Monte Carlo estimates. The checker tests them against the exact values.
Simulate a random walk and the walk of many walkers. The checker tests the shape of the walk, the size of the steps and the law of the mean squared distance.
Simulate the decay of a sample, and find its half-life in whole seconds. The checker compares the result with the exponential law.
Write the formula for the standard error of the mean and the bootstrap, and see that they agree. The checker uses a fixed list and a long list of numbers.
Write the functions of the pendulum project. The checker uses exact periods, and then a simulation of 1000 experiments.
Write three tools that find slopes from numbers. The checker compares them with the exact slopes.
Write the rules for areas as functions. The checker tests them on curves with known areas.
Use quad for three jobs. The checker compares your answers with known values.
Write Euler's method for one quantity that changes with the rate dy/dt = rate(t, y). The checker tests it on two equations with known answers.
Measure the error of Euler's method for a falling ball with air drag, and see that it is first order. The checker compares your function with known numbers.
Write the functions of the projectile project with air drag. The checker compares them with the physics without air, and with known values with air.
Write the bisection method as a function. The checker solves four equations and tries a function without a change of sign.
Write Newton's method with the two safety rules: a limit of steps, and a stop when the slope is zero. The checker tries good and bad cases.
Write three small tools with the polynomial functions of NumPy. The coefficients are listed from the highest power down. The checker uses polynomials with real and with complex roots.