Interactive, runnable Python. Edit the code, run it in your browser, no setup required.
You will write three functions about the hot early universe. The idea. The CMB is at 2.725 K today and its temperature is 2.725(1 + z) kelvin at redshift z. Wien's law gives the peak, λ = 2.898 × 10^-3/T metres. The c…
You will write two small tools for chromatography. The idea. An Rf is the spot distance over the solvent distance. In gas chromatography each area divided by its response factor is proportional to the mass. Your tasks…
You will write a small tool that tests a claim about whole numbers and reports the first counterexample. The idea. A claim "for every n from start to stop, P(n)" fails at the first n with P(n) false. A search can find…
You will plan the fuel of a migrant, predict the error of a clock-shifted bird, and follow a clock that runs free. The idea. The fat needed is the power times the flight time, divided by 39 000 J per gram. The flight…
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 the whole method for quarterly data: centred moving averages, seasonal components and a forecast. The idea. Centre the 4-point averages by taking the mean of each neighbouring pair. The first centred va…
You will turn an output column into a logic expression by the method of the lesson: one AND term for each row with X = 1, joined by OR. Your tasks. In term, return the AND term for one row. An input that is 1 is writt…
You will write three functions that help to choose binoculars for the night sky. Lengths are in millimetres. The idea. For binoculars M × D the exit pupil is D/M. The light grasp compared with an eye pupil p is (D/p)^…
You will write three functions about the expansion of the universe. Speeds are in km/s, distances in Mpc. The idea. For small redshifts v = cz, with c = 3.00 × 10^5 km/s. Hubble's law is v = H_0d. The Hubble time is 1…
You will write the functions that decide how to split a solvent between extractions. The idea. After one shake of a volume v of solvent with a volume V of water, the fraction of solute left in the water is V/(V + Kv).…
You will write a program that decides whether an argument is valid by checking every row of its truth table. The idea. An argument is valid when no row makes every premise true and the conclusion false. Premises and t…
You will rank prey by profitability and find the best time to stay in a patch that runs down. The idea. Profitability is E/h. In a patch the gain after t seconds is G(1 - e^-t/k), and the rate over a trip is the gain…
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…
You will write a function that finds the moving averages of a time series for any number of points, and use it to see which length removes a seasonal swing. The idea. A k-point moving average is the mean of k values i…
You will code the circuit X = (A AND B) OR (NOT C) and build its truth table in the syllabus order. Your tasks. In circuit, return X for the inputs a, b and c. Set rows to the 8 input rows (a, b, c) in binary order. S…
You will write three functions about the brightness of stars. The idea. A star of magnitude m_1 looks 100^(m_2 - m_1)/5 times as bright as a star of magnitude m_2. A brightness ratio r is a difference of 2.5_10r magni…
You will write three functions that astronomers use to find and measure planets. Masses are in solar masses, distances in AU, times in years. The idea. Kepler's third law in these units is M = a^3/T^2. A transit of de…
You will write the functions that turn a page of titres into a result with its uncertainty. The idea. Concordant titres agree within 0.10 cm³. A titre is uncertain by 0.10 cm³. Percentage uncertainties add for product…
You will write three functions that test quantified claims on a finite set of numbers. The idea. "For every x in the set, P(x)" is true when no x fails. "There exists x with P(x)" is true when at least one x works. A…
You will work out the relatedness of worker bees, test Hamilton's rule, and find how safe a flock is. The idea. Two workers whose mother mated with n males have an average relatedness of 0.25 + 0.5/n. Helping is favou…
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 build a small cost of living index from what a household bought in the base year. The idea. Each weight is the base-year spending: quantity × base-year price. The index is Σ (w × price relative)Σ w. The cost…
You will write a function that names a two-input gate from its output column, and a function that builds the 8 rows of a three-input truth table in order. Your tasks. In name_gate, return the name of the gate in GATES…
You will write three functions about the turning sky. Times are in hours or minutes, as each task says. The idea. In a year of N solar days the Earth turns N + 1 times relative to the stars, so the sidereal day is 24N…
You will write three functions about stars on the main sequence. Masses and luminosities are in solar units, times in years. The idea. On the main sequence, L = M^3.5 and the lifetime is t = 10^10 × M^-2.5 years. A cl…