A data logger records a pump's average power over four consecutive intervals. An engineer computes energy with this code:
import numpy as np P = np.array([1.2, 1.5, 0.9, 2.1]) # average power, kW t = np.array([0.5, 0.25, 1.0, 0.75]) # interval duration, h E = np.sum(P[1:] * t[1:])
What value does E hold? Give your answer in kWh to two decimal places.
Unlock full course notes by signing up
Splitting a test duration with // and %
A data logger records the duration of a fatigue test as an integer number of seconds. A Python script splits it into hours, minutes and seconds, and also computes one extra value r:
Give the value that Python stores in each of h, m, s and r. Each answer is an exact integer.
Lists versus arrays under multiplication
An engineer intends to double three loads, measured in kN, and checks the results by comparing their totals:
What value does result hold, and what does it reveal about the engineer's check? The tuple contains the number of elements in a, the mean of a in kN, and the mean of b in kN, respectively.
Writing a vectorized RMS function
An oscilloscope records these voltage samples across a resistor:
The root-mean-square value of NNN samples is
Ranking expressions by operator precedence
Each item below is a complete Python expression typed at the interpreter. Evaluate each one using Python's operator precedence and associativity rules, then arrange the expressions from the smallest resulting value to the largest.