A4 Python for engineers · Practice
Two-dimensional arrays
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
The starter makes X, 200 samples of 5 channels. Set means to each channel's mean, rms to each channel's RMS (), and loudest to the index of the channel with the largest RMS.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
For every pair of E6 resistor (100 Ω to 680 kΩ) and capacitor (1 nF to 6.8 µF) in the starter, compute the corner frequency as a 2D array fc (rows for capacitors, columns for resistors). Set R_best, C_best to the pair whose corner is nearest target = 2000 Hz in ratio (smallest ).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Set M to the n × n array (4 × 4) whose entry at row i, column j is , using broadcasting (no loops). Then set diag to its diagonal and col_sums to the sum of each column.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
The starter makes T, an n × n grid of temperatures (5 × 5). Using slices and no loops, set inner to the grid without its outer border, and avg4 to the average of each inner point's four neighbors (up, down, left and right), an array the same shape as inner.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
An ADC sends m = 3 channels interleaved: channel 0's sample, then channel 1's, and so on, then channel 0 again. The starter's data holds 200 rounds of them. Set X to the samples as one row per round and one column per channel, and p2p to each channel's peak-to-peak value (its maximum minus its minimum).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Set A to np.arange(r * c) reshaped into r = 3 rows and c = 3 columns, and last_col to its last column.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Set row_max to the largest value in each row of X, and where to the column where each row's maximum is.
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