π» Activity: Practice with Variables and Operators#
1.2.1 Using Variables to Make a Price List#
You are working for your favorite grocer and they want you to calculate the price of goods at checkout. Here is a list of prices:
Item |
Price per pound |
---|---|
Apples |
$1.50 |
Oranges |
$2.00 |
Bananas |
$0.75 |
Carrots |
$1.25 |
Beef |
$5.00 |
Salmon |
$8.00 |
Shrimp |
$9.00 |
Item |
Quantity |
Price |
---|---|---|
Bread |
1 loaf |
$3.00 |
Milk |
1 gallon |
$3.50 |
Eggs |
1 dozen |
$3.00 |
Cheese |
1 lb |
$5.00 |
Yogurt |
6 pack |
$4.50 |
Purchases:
Item |
Quantity |
---|---|
Apples |
3 lbs |
Oranges |
2 lbs |
Bananas |
1 lb |
Carrots |
0.5 lb |
Bread |
1 loaf |
Milk |
1 gallon |
Eggs |
1 dozen |
Cheese |
1 lb |
Yogurt |
6 pack |
A. Write a python script to calculate your bill. B. Write a print statement the prints the total cost of your bill.
# your solution goes here
1.2.2 Planning for Paving a Driveway#
You are tasked with ordering asphalt to pave a driveway that is 12 feet wide, and 28 feet long. You want the end pavement to be 3 inches thick. When water is added to mix the asphalt it expands by 20% in volume, after pouring the asphalt reduces in volume by 31 percent. How much asphalt mix will you need to purchase. If it costs $1.03/cubic ft., what is the cost? You should include a safety factor (an excess) of 10% for material lost during processing.
# your solution goes here
After you do the calculation your boss runs back to you and says he found a product that expands by 30 percent on mixing and shrinks by 12 percent on setting. The problem is it cost $1.40/cubic ft.. Which product should you go with?
# your solution goes here