Question: This is python,can someone help to get the solution or explain?] Updating a variable by adding or subtracting a number to the original contents of
This is python,can someone help to get the solution or explain?] Updating a variable by adding or subtracting a number to the original contents of the variable has its own shorthand to make it faster and easier to read.
money_in_wallet = 40 sandwich_price = 7.50 sales_tax = .08 * sandwich_price sandwich_price += sales_tax money_in_wallet -= sandwich_price In the above example, we use the price of a sandwich to calculate sales tax. After calculating the tax we add it to the total price of the sandwich. Finally, we complete the transaction by reducing our money_in_wallet by the cost of the sandwich (with tax).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
