Maths Operations
Challenge 1-4: Variables
We can also use variables to do some of the same things we do with numbers and strings.
Let's create a couple of variables and give them numeric values. We can use our puppies example from earlier, and also create one new variable. Give that new variable a value of three.
>>> puppies = 12 * 12
>>> fishes = 3
Now what happens if we add the two variables? Is the answer what you expect?
>>> puppies + fishes
Go ahead and try some other math operations with these two variables. You can subtract, divide, multiply, even compare them.
>>> puppies - fishes
>>> fishes - puppies
>>> fishes * fishes
>>> puppies / fishes
Answers
>>> puppies + fishes
147
>>> puppies - fishes
141
>>> fishes - puppies
-141
>>> fishes * fishes
9
>>> puppies / fishes
48.0