Utility functions

One thing that wasn't addressed in the requirements but will be necessary later is the need for utility functions. These are often found in applications and provide functionality for the main program, but don't directly apply to the core logic.

For this program, we will require a number of utility functions:

  • Calculate liquid flow rate due to gravity
  • Static hydraulic pressure of a fluid due to its height
  • Conversion programs for pressure: specifically, we need to convert fluid head (measured in feet) in to pounds per square inch (PSI)

The functions are shown next (in separate parts), with explanations following each part:

# utility_formulas.py (part 1)1 #!/usr/bin/env python3 2 3 import math 4 5 GRAVITY = 32.174 # ft/s^2 ...

Get Learn Programming in Python with Cody Jackson now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.