Designing algorithms
As previously mentioned throughout this chapter, an algorithm is a set of instructions. When we are writing a computer program, the algorithm is a set of instructions given to the computer so it can provide a solution to a posted problem. We have been sticking to mathematical algorithms so far only because we haven't done a deeper dive into Python yet. However, we will now translate some of the algorithms into Python programming.
First, let's take a look at Problem 1. Here, we had a situation where you can win $250 or your height in quarters. Assuming it is you who's competing, you would want to know which option gives you the most in winnings.
Let's take a look again at our mathematical algorithms from earlier in this chapter:
- Total winnings (customary):
- Total winnings (metric):
Remember, if you are using your height in customary units, you'll use the first algorithm. If you are using metric units, you'll...