Interactive, runnable Python. Edit the code, run it in your browser, no setup required.
You will build logic gates from one gate, the NAND gate, as a factory would. The idea. A NAND gate gives 0 only when both inputs are 1. NOT is a NAND gate with its two inputs tied. AND is a NAND gate followed by a NOT…
You will write a small program that finds the lone pairs, the steric number and the shape of an interhalogen or xenon compound. The idea. The central atom has some outer electrons. Each bonded atom uses one of them. T…
You will model a delivery problem in code and search all the whole-number plans for the cheapest one. The idea. Depot D1 holds 30 crates and depot D2 holds 40. Shop S1 needs 25 crates and shop S2 needs 35. Let x crate…
You will write functions for the viability of a stored seed lot, for the time until the lot must be grown out, and for the threatened categories of the IUCN Red List. The idea. In a model, viability is start * 0.5 (ye…
You will fit a sine to 60 noisy readings of a swinging spring, with a first guess from the FFT. The idea. The FFT finds the main frequency to within one bar. curve_fit then refines the amplitude, the frequency and the…
You will build a function that summarises any list of numbers: how many, the mean, the median, the range and a chance. Then it summarises the month, and the definition of a hot day is yours to choose. The idea. A summ…
You will write four functions that a designer uses for a transistor in the common-emitter circuit. The idea. β = (α)/(1 - α). In a circuit with one supply, I_B = V_CC - 0.7R_B, I_C = β I_B and V_CE = V_CC - I_C R_C, a…
You will finish a program that predicts which halogens oxidise which halide ions. It works from the standard electrode potentials. The idea. A halogen oxidises the halide of another halogen if its potential is higher.…
You will model the workshop of the first lesson in code and search all the whole-number plans for the best one. The checker tests your functions on many plans. The idea. A plan is a pair (x, y) of tables and chairs. C…
You will write functions for the share of each zone of a model biosphere reserve, for the area of the hotspots, and for the extinctions that protection avoids. The idea. A reserve is a set of nested squares. The core…
You will draw a wave of wavelength 3.0 m and frequency 4.0 Hz at two times, find its first crest each time, and work out its speed. The idea. The crest of y = A(kx - ω t) moves at the speed v = fλ. You find where the…
The month of 30 days is in two lists: the temperatures and the rainy days. You will split the temperatures into rainy and dry days, and count how many days had each temperature. Then the program draws a line graph wit…
You will write four functions that describe a Zener regulator and its limits. The idea. The series resistor carries I_s = V_in - V_zR_s. The load takes (V_z)/(R_L) and the Zener diode takes the rest. The limits on R_s…
You will write functions that find the oxidation state of sulphur in an oxoacid, tell whether the acid has an O-O peroxide link, and list the acids that have a given state. The idea. Oxygen is -2, except in an O-O lin…
You will wrap scipy.optimize.linprog in three small functions, so that you can check any problem of this chapter in one line. The idea. linprog minimises c_1x + c_2y subject to Ax ≤ b and x, y ≥ 0. To maximise, give i…
You will write functions for the core of a forest cut into pieces, for the forest that has been lost, and for the number of pieces at which the core vanishes. The idea. A forest of side 10 km is cut into k by k equal…
You will write three small functions that check a claimed identity on many angles: one finds the worst miss between the two sides, one says whether the identity holds, and one finds an angle where it fails. The idea.…
You will find the exact probability of each sum of two dice by listing the 36 pairs, then roll two dice 3,600 times and compare. The program draws both side by side. The idea. The exact probability counts equally like…
You will write four functions that a power-supply designer uses for a rectifier and its smoothing capacitor. The idea. For an ideal half-wave rectifier the mean output is V_m/π. For a full-wave rectifier it is 2V_m/π.…
You will write three functions for the reaction 2KClO_3 → 2KCl + 3O_2. The first finds the volume of oxygen from a mass of the salt. The second finds the mass of the salt that is needed for a volume. The third finds t…
You will write three small functions for the corner point method. The checker tests them on regions with ties and with negative numbers. The idea. For Z = ax + by, work out Z at each corner. The best value is the larg…
You will write functions for the share of a group among the extinct species, for the number of species lost in a century, and for the yearly loss of a model community. The idea. A share is the part divided by the whol…
You will write three small functions for angles: one that converts degrees to radians without math.radians, one that finds the quadrant of an angle, and one that returns the point of the unit circle at an angle. The i…
You will toss a coin 500 times in a program, keep the share of heads after every toss, and draw how that share moves. Then you see how close the last share comes to 0.5. The idea. The share of heads jumps about in a s…
You will write four functions that describe a silicon diode, from the diode equation to a diode in series with a resistor. The idea. The diode equation is I = I_s(e^V/V_T - 1), with V_T = (kT)/(e). In a circuit, a con…