A4 Python for engineers · Practice
Lab: instrument data, text and bits
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
Check
A meter answers a "read all" query with comma-separated readings in E notation. Write stats(reply) returning (mean, pk2pk), the mean and the largest minus the smallest reading. Then set s = stats(reply) for the reply the starter picks.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write volts(b, vref=2.048) for a 24-bit bipolar converter: three bytes, most significant first, two's complement, volts per count. Then set v for the bytes the starter picks.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A bench supply takes the commands VOLT <v> and CURR <i>, with the voltage to 3 decimals and the current to 4, then OUTP ON. Write setup(v, i) returning the three commands as one string separated by "\n". Then set cmd = setup(v, i) for v = 1.25 and i = 0.01.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A converter's control register takes the channel in bits 0 to 3, a gain code in bits 4 to 6, and a start flag in bit 15. Write control(ch, gain, start) returning the register value, and decode(reg) returning (ch, gain, start) back from it. Set reg = control(ch, gain, start) for ch = 5, gain = 0 and start = 1, and back = decode(reg).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write table(rows) that formats a list of (name, value, unit) rows as text, one row per line: the name left-aligned in 8 characters, the value right-aligned in 10 characters with 4 significant figures (.4g), a space, then the unit. Set text = table(rows) for the rows the starter picks.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A bipolar 16-bit converter covers −1.25 V to +1.25 V. How many volts is one count?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in A4