A4 Python for engineers · Practice
Problem set 4: collections
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
Each string in the starter's list is like "R1=4.7k". Using the parse function given, set bom to a dictionary from each name to its value in base units.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Set m and s to the mean and sample standard deviation of x, then outliers to the readings more than 2 standard deviations from the mean, in their original order.
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 parts connect to each node. Set degree to a dictionary from node name to that count.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
For the sweep in the starter, set gain_db to the list of gains in dB (), and f3 to the first frequency whose gain is more than 3 dB below the first one's.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Each part is a tuple (name, ohms). Set ranked to the list of names sorted by the power each dissipates at V = 5 V, largest first.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Set avg to the moving average of x over a window of w = 4: entry i is the mean of x[i:i+w], for every full window.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Some strings in the starter's list aren't numbers. Set total to the sum of the ones that are, and bad to how many weren't, using try and except ValueError.
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