Lab description:
This lab test my knowledge learned from the class lecture and from the “Phyton Syntax” (tutorial) in order to apply it to a real world example, which is eating at a restaurant, to calculate the total cost of a meal. For this lab variables, values and assignment statements where used in order to accomplish the objective. Each picture represents each the steps that were done to calculate by setting values to the variables.
The given information in the lab:
- Cost of meal : $44.50
- Restaurant Tax: 6.75%
- Tip: 15%
My experience:
Doing this lab made me feel as an actual programmer or coder. I learn that Python is not just a programming language for just the purpose of creating programs. Python can be used for many things, including of course making a program, but also for the purpose of calculating just like it was done in this lab. In order to give a value to a variable, you must type the “variable” “=” “value”. I notice something in particular on step two in which phyton does not take the percentage sign (%) as a percentage, instead you have to convert the number as a percentage before placing it as a value. This is done by dividing the number by 100. For example, the “restaurant tax” should be as 0.0675 instead of 6.75%. This is how python reads percentages. Later on I redefined the value for the variable of “meal” to “meal + meal * tax”. At the end I set the variable “total” = “meal + meal + tip” which calculate the total cost of the meal.