Learn
You might have considered the situation where you would like to reuse a piece of code, just with a few different values. Instead of rewriting the whole code, it’s much cleaner to define a function, which can then be used repeatedly.
Instructions
1.
Check out the code in the editor. We’ve def
ined two functions: tax
to calculate the tax on a bill, and tip
to compute the tip.
See how much of the code you understand at first glance (we’ll explain it all soon). When you’re ready, click Run to continue.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.