Audit the complete engineering function contract

An engineering function has this Python 3 signature:


Python
def pumping_power_kw(flow_l_s, pressure_kpa, efficiency):
    # function body goes here


Its contract requires nonnegative flow in litres per second, nonnegative pressure increase in kilopascals, and an efficiency satisfying 0<η≤10<\eta\leq1. All inputs are finite real numbers. Any input outside this domain must raise ValueError; otherwise, the function must return input power in kilowatts.


Use


Pin=Δp Qη,1 L=10−3 m3,1 kPa=103 Pa,1 kW=103 W.P_{\text{in}}=\frac{\Delta p\,Q}{\eta},\qquad 1\ \text{L}=10^{-3}\ \text{m}^3,\qquad 1\ \text{kPa}=10^3\ \text{Pa},\qquad 1\ \text{kW}=10^3\ \text{W}.


Which function body satisfies the entire contract, including its boundary cases?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More User-Defined Functions Questions: