Module 2 · Variables · Lesson 6 of 8
Solving simple problems
You now have everything you need to make a computer actually compute something. The recipe is always the same: store the inputs in well-named variables, build an expression that works out the answer, store that in another variable, and print it.
Take converting a temperature from Celsius to Fahrenheit. The formula is F = C × 9 / 5 + 32. Notice how precedence quietly does the right thing here — * and / happen before the + 32:
Change celsius and run it again — the whole calculation follows along, because everything below it is built from that one variable. That's the payoff of naming your data.
Now your turn. Here's a bill-splitter: it adds a tip, then divides between everyone. Read it, predict the answer, then run it — and try tweaking the numbers.
Updating a variable from itself — like adding things up as you go — is so common that Python has a shorthand for it. That's next.