Python as a Calculator
You can use Python to perform calculations using the four basic operations:
+
Addition-
Subtraction*
Multiplication/
Division
You can also use parentheses to control the order of operations:
(45/5 + 23) * 100
Output:
3200.0
Exercises
Use Python to solve the following:
-
Calculate how many seconds are in one year.
-
A bakery is making cupcakes for a party. They need to bake 4 batches of cupcakes, with 12 cupcakes per batch, and then add sprinkles to half of the total cupcakes. How many cupcakes will have sprinkles?
-
Compute the area of a triangle with a 6-foot base and a height of 125 inches using the formula: area equals one half times base times height.
Hint: don’t forget to convert units.