A411 of 56
0 XP
  1. Hook
  2. Problems

A4 · Problem set 2

Problem set 2: the basics

These labs use lessons 1 to 10: numbers, strings, conditionals, loops and functions. Each one is a small, complete engineering calculation. Read the hidden tests' messages when a check fails: they say which case went wrong.

Check

Write battery_life(capacity_mAh, current_mA, derate=0.8) returning the hours a battery lasts when only derate of its rated capacity is usable. Set h1 = battery_life(Q, I) and h2 = battery_life(Q, I, derate=1.0) for Q = 1000 mAh and I = 0.5 mA.

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

Check

TTL logic reads an input as low at or below 0.8 V, high at or above 2.0 V, and undefined in between. Write level(v) returning "low", "high" or "undefined", and set s = level(v) for v = 0.8 V.

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

Check

Add up ∑1/k2 for k=1,2,3,…, stopping before the first term smaller than tol = 1 × 10⁻⁸. Set total to the sum and n to how many terms you added.

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

Check

A diode and a resistor R = 220 Ω are in series across Vs = 5 V. The diode's voltage is Vd=0.025ln⁡(I/10−14). Starting from I=(Vs−0.7)/R, repeat I←(Vs−Vd(I))/R until I changes by less than 10−15 A. Set I to the result and Vd to the diode's voltage then.

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

Check

Write ones(n) returning how many 1 bits a non-negative integer has, using % and // (no bin). Set c = ones(n) for n = 95.

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

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