A4 Python for engineers · Practice
Tuples, dictionaries and sets
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
Using the DIGIT dictionary in the starter, write decode(b1, b2, mult) for a three-band resistor. Then set value for the bands 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
Count how many of each kind of part (the first letter of each name) the list holds. Set counts to a dictionary like {"R": 3, "C": 2}.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Set nodes to the set of every node in the netlist, and n to how many there are.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Build parts as a dictionary mapping "R1" to R = 470 and "R2" to twice that. Then add "R3" equal to the two in series, and set total to the sum of all three values.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
The starter's netlist is a list of (part, node_a, node_b) tuples. Set on_node to a dictionary mapping each node name to the sorted list of parts that touch it.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Set common to the set of nodes that appear in both lists.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Make the tuple pt = (x, y) and then unpack it into px, py. Set d to the distance from the origin.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
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