The mortgage calculation example
I used the example of the Canadian mortgage calculation formula as a complex
formula whose calculation could demonstrate a variety of Python language
features.
Here are the versions produced/shown in class:
- mort1.py: the big nasty formula. No good.
- mort2.py: Giving names to portions of the formula
results in a readable program.
- mort3.py: Putting it in a procedure.
- mort4.py: A parameterized procedure, which is more
useful than the mort3 version.
- mort5.py: A procedure which returns a value
instead of printing, so that the procedure call is an expression rather than a
statement.
[back to topic list]
[main course page]