Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
The print function
Variables
Math in Python
17. Parentheses in mathematical operations
The input function
Summary

Instruction

Good. One final remark with regard to math in Python: you can use parentheses to change the order of operations:

order_a = 12 * 4 + 5
order_b = 12 * (4 + 5)

Multiplication takes place before addition, so order_a equals 12 * 4 + 5 = 48+5 = 53. In order_b, we introduced parentheses, so order_b equals 12 * (4 + 5) = 12 * 9 = 108.

Exercise

A florist sells roses and tulips in his florist shop. One day, he prepared 150 roses for 50 cents each, and 100 tulips for 40 cents each. He sold everything but 15 roses and 25 tulips. Calculate the difference between his earnings from roses and his earnings from tulips. Then, express the amount in dollars. Print the result.

Stuck? Here's a hint!

First, you have to calculate the number of sold roses, and amount of money earned from the sale:

(150 - 15) * 50

Then, we need to do the same for tulips:

(100 - 25) * 40

Our next step is to calculate the difference between these two results:

(150 - 15) * 50 - (100 - 25) * 40

Finally, we can express the amount in dollars:

((150 - 15) * 50 - (100 - 25) * 40) / 100