3.3 Using super flexible keyword parameters
Some design problems involve solving a simple equation for one unknown when given enough known values. For example, rate, time, and distance have a simple linear relationship. We can solve for any one when given the other two.
There are three related solutions to r × t = d:
When designing electrical circuits, for example, a similar set of equations is used based on Ohm’s law. In that case, the equations tie together resistance, current, and voltage.
In some cases, we want an implementation that can perform any of the three different calculations based on what’s known and what’s unknown.
3.3.1 Getting ready
We’ll build a single function that can solve a Rate-Time-Distance (RTD) calculation by embodying all three solutions, given any two known values. With minor variable name changes, this applies to a surprising...