#!/usr/bin/env python # coding: utf-8 # In[27]: # Section 2.7 -- Calculations # Math operations # + -- addition print(5+2.0) # - -- subtraction print(2-5) # * -- multiplication # print((2.0)(3)) <-- this is an error -- Python thinks "(2)" is a command print(2*3) # / -- division (float) print(2/3) print(-2/3) # // -- division (int) print(2//3) print(-2//3) print(15/2) print(-15/2) print("15//2=",15//2) print("-15//2=",-15//2) # % -- modulus ("remainder") print("7%2=",7%2) print("22%5=",22%5) print("14%1.6=",14%1.6) print("14/1.6=",14/1.6) # ** -- exponentiation # print(2^3) <-- this does bitwise XOR (see COMP 1120 for more details) print("2**3=",2**3) # print "this" <-- python 2 used to allow this, but python 3 does not # In[38]: # Calculate the price of an item in a place where # there is a 7% sales tax # Get the listed item price: listed_price=float(input("What is the listed price of this item?")) print(type(listed_price)) # calculate the tax tax=0.07*listed_price # print the actual price print("The actual price is=$",listed_price+tax)