Assignment#1: Tip Calculator
The code academy lesson “Tip Calculator” shows how to use python to calculate the amount of a tip should be given after a meal.
Since the cost of a meal is $44.50, the variable “meal” is assigned to “44.50” on line 1.
The tax for the meal is 6.75% of the total cost. This is why the variable “tax” is assigned to .0675(6.75% in decimal form) as shown on line 2.
The service for the meal was good, so I would like to leave a 15% tip. Since I want to calculate a 15% tip, the variable “tip” is assigned to 15% as a decimal, which is “.15” on line 3.
Since the cost of the meal and the tax is known, the total cost of the meal can be calculated by reassigning the variable “meal” to “meal + meal * meal” to get the total cost of the meal. This is shown in line 7.
Finally, the total cost, which is the sum of the cost of the meal and the tip, must be calculated. This task can be completed by creating a new variable like “total” and assigning it to “meal + meal * tip.