November 2018
Beginner
304 pages
7h 35m
English
Having written all of the code for any generic pump, we now write the code for centrifugal pumps, which are the most common type of variable displacement pumps. This code is shown here:
# pump.py (part 9)1class CentrifPump(Pump):
2 """Defines a variable-displacement, centrifugal-style pump."""
3
4 def get_speed_str(self):
5 """Get the current speed of the pump, in rpm."""
6 if self.speed == 0:
7 return "The pump is stopped."
8 else:
9 return "The pump is running at {speed} rpm.".format(speed=self.speed)
10
11 def get_flow_str(self):
12 """Get the current flow rate of the pump."""
13 return "The pump output flow rate is {flow} gpm.".format(flow=self.flow)
Line 1 subclasses the Pump base class to create the CentrifPump ...
Read now
Unlock full access