What does it mean for code to be reusable and what good is that?
Answer
You may hear people mention DRY programming, which stands for Don’t Repeat Yourself. Simple enough, but you’d be surprised how much time and effort you’ll save by following through with it!
Often at times we’ll write code that needs some functionality repeated several times, perhaps even with different values each time. For example, if we tried to calculate the cost of a bill and tip for every meal, we’d have to write out the entire calculation each time for every different meal!
Wouldn’t it be better if we could give the cost of the meal to a function and have it handled the same way regardless of what the meal is or how much it cost?
That’s what we’ll be looking into for the next little while! Making functions that are able to do some action given some input and produce some output, all in the name of saving time and energy!
The asterisk (*) is a multiplication symbol in this usage.
For example if sales tax was 8 percent and you want to know how much something is once you add tax it could be written as follows:
bill *= 1.08
"""because if you multiply something times 1, it stays the original amount. If you multiply an amount by 1.08 it remains the same figure plus 8 percent more. so it multiplies the amount that (bill) represented"""