A426 of 56
0 XP
  1. Hook
  2. Problems

A4 · Problem set 6

Problem set 6: program structure

These labs use lessons 19 to 25: the standard library, classes, state machines, recursion and searching, running time, and sorting. They're closer to real tools: an impedance sweep, a component model, a solver, a Monte Carlo check.

Check

For a series RLC with R = 10 Ω, L = 1 mH and C = 1 µF, set Z to a list of complex impedances at the frequencies in fs, and fmin to the frequency in fs where |Z| is smallest.

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

Check

Write a class Capacitor with attributes C (farads) and esr (ohms) and a method impedance(f) returning the complex ESR+1/(jωC). Set z = Capacitor(C * 1e-6, esr).impedance(f) and mag = abs(z).

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

Check

An RC low-pass has |H|=1/1+(f/fc)2 with fc = 1000 Hz. Use bisection between fc and 1000 * fc to set f to the frequency where |H| = g = 0.5, to within 1e-9 relative.

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

Check

An R-2R DAC adds vref/2 for its first bit, vref/4 for the second, and so on. Write a recursive dac(bits, vref) for a list of 0s and 1s (most significant first), and set v = dac(code, vref) for the starter's code.

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

Check

Two resistors of 10 kΩ ±t% each form a 50% divider. With random.seed(1), draw 10,000 pairs (each resistor 10e3 * random.uniform(1 - t/100, 1 + t/100), top then bottom) and set frac to the fraction of dividers whose ratio is within ±spec% of 0.5.

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.