In: Computer Science
Write a program function code in Python that prompts the user to enter the total of his/her purchase and add 5% as the VAT. The program should display the total without and with VAT.
( that mean i should ask the user to enter the number of their item " so i think that i should use range"
then print the result with and without the VAT )
WE NEED NOT TO USE range if there is only one purchase...!! SOURCE CODE: *Please follow the comments to better understand the code. **Please look at the Screenshot below and use this code to copy-paste. ***The code in the below screenshot is neatly indented for better understanding. # read the purchase total as the float value total_purchase = float(input('Enter the total of your purchase: ')) # print the total without VAT print('Your total purchase without VAT is:', total_purchase) # calculate VAT for the total purchase VAT = (5 * total_purchase) / 100 # add VAT total_purchase_with_VAT = total_purchase + VAT # print the total with VAT print('Your total purchase with VAT is:', total_purchase_with_VAT)
=======
RUN 2
IF WE WANT MORE THAN ONE PURCHASE
# read number of items user want's to enter n = int(input('Enter number of items you want to enter: ')) # take total = 0 total_purchase =0 # loop from 0 to n for i in range(n): # read the purchase total as the float value purchase = float(input('Enter the item of your purchase: ')) # add that purchase total_purchase += purchase # print the total without VAT print('Your total purchase without VAT is:', total_purchase) # calculate VAT for the total purchase VAT = (5 * total_purchase) / 100 # add VAT total_purchase_with_VAT = total_purchase + VAT # print the total with VAT print('Your total purchase with VAT is:', total_purchase_with_VAT)
=========