A4 Python for engineers · Practice
Text and CSV data
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
Read the CSV text in the starter with csv.DictReader. Set names to the list of header names, n to the number of data rows, and vmax to the largest value in the v column.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Load the numeric CSV in the starter with np.loadtxt (it starts with a comment line and a header). Set t, v to its first two columns and avg to the mean of v.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
The log in the starter has missing entries. Read it with np.genfromtxt and set missing to how many values are missing and means to the mean of each column, ignoring them.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Compute an RC low-pass's gain in dB at f = [10, 100, 1000, 10000] for fc = 500 Hz, and set text to CSV with the header f,gain_db and the gains to three decimal places, one row per frequency, joined with "\n".
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Each line of the starter's log looks like 12:00:05,3.301: a time of day as hh:mm:ss, then a reading. Set secs to a list of each line's time in seconds since the first line, vals to the readings as floats, and rate to the average number of readings per second over the log (lines minus one, divided by the elapsed time).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Set cols to a dictionary from each header name to a list of floats for that column.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
The column header says i_mA. Load the text and set i to the currents in amperes.
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