A456 of 56
0 XP
  1. Hook
  2. Problems

A4 · Final exam

Final exam: Python for engineers

Five labs drawn from the whole course, weighted toward its second half: arrays, plots, numerical methods and data. Give yourself two and a half hours and work without the lessons open. Each lab is graded by hidden tests; if one fails, read its message, fix, and check again. "Another set" deals a different exam.

Check

An n-th order Butterworth low-pass has |H|=1/1+(f/fc)2n. For n = 2 and fc = 300 Hz, on 500 log-spaced frequencies from fc/100 to 100fc, set gdb to the gain in dB and slope to the roll-off in dB per decade measured between 10fc and 100fc (the last two decades' endpoints).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Read the CSV in the starter (a comment line, a header, then t in ms and v in mV), convert to seconds and volts, and set t, v, then vpp (peak to peak, V) and f_est: the frequency estimated from the average spacing of rising zero crossings of v - v.mean().

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Integrate dv/dt=(5−v)/τ−0.1v2 from v=0 to t=5τ with RK4 in n = 50 steps and with 2 * n steps (tau = 1). Set v1, v2 to the two final values and est to the estimated error of v2, |v1−v2|/15.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A divider of 10 kΩ over 10 kΩ feeds an RC low-pass of 10 kΩ and 100 nF; the output is at the capacitor. Model every resistor as uniform ±tR% and the capacitor as uniform ±tC%. With default_rng(3), draw 100,000 boards (top, bottom, filter R, then C). The DC gain is the divider ratio, and the corner is 1/(2πRthC+2πRfC) where Rth is the divider's Thevenin resistance. Set gain, fc (arrays) and yld: the fraction with gain within ±2% of 0.5 and corner within ±5% of nominal.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

The starter makes a record of two tones in noise, sampled at 8 kHz for 8000 samples. Using a Hann window (np.hanning) before np.fft.rfft, set peaks to the sorted frequencies of the two largest local maxima of the spectrum's magnitude (ignoring DC).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Have paper and a calculator ready. Work each problem out by hand, then enter the answer. Your first try on each one counts toward your score.

Practice

Keep practicing

8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.