# Tutorial_1_Problem_2.py # # Write a Python program that adds a tax to a given price. Your program must ask the user for a price (float), then a tax (float). # The format of the tax to be entered is, for example, 0.12 instead of 12%. # The user will always enter a valid positive float value as a price and as a tax. # For example: # • if the user enters the price 2.65 and the tax 0.07 (i.e., 7%), then your program produces and prints 2.84. # • if the user enters the price 12.85 and the tax 0.12 (i.e., 12%), then your program produces and prints 14.39. # Hint: # • You may appreciate the built-in function round(,2). # # If you find it useful to start by designing an algorithm, feel free to do so. # # Anne Lavergne # 2016 # Asking user for input price = float(input("Please, enter the price as a float: ")) tax = float(input("Please, enter the tax as a float (for example, 0.12 instead of 12%): ")) # Compute the result # result = price * (1+tax) <- also works! result = price * tax + price # Round up to 2 sig. fig. result = round(result,2) # Report print("Price ({0}) + tax ({1}) = {2}.".format(price, tax, result))