Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- #declare variables
- item_name = [""] * 30
- item_price = [0.0] * 30
- item_vat = [0.0] * 30
- item_vat_num = [0.0] * 30
- anymore = "YES"
- VAT = 0.8
- VAT2 = 0.2
- counter = 1
- counter2 = 1
- num_item = 1
- random_num = 0
- random_num2 = 0
- discount_a = 0.0
- discont_b = 0.0
- #get items and calculate VAT
- while anymore.upper() == "YES":
- print("Please enter the name of item ",counter,".",sep = '')
- item_name[counter] = str(input())
- print("Please enter the price of ",item_name[counter],".",sep = '')
- item_price[counter] = float(input())
- item_vat[counter] = item_price[counter] * VAT
- item_vat_num[counter] = item_price[counter] * VAT2
- counter = counter + 1
- num_item = num_item + 1
- print("Would you like to select another item?")
- anymore = str(input())
- if anymore.upper() == "NO":
- anymore = "no"
- #find random discount
- random_num = random.randint(1,(num_item - 1))
- random_num2 = random.randint(1,(num_item - 1))
- if random_num == random_num2:
- random_num2 == random.randint(1(num_item - 1))
- #display items
- for loops in range(1,num_item):
- print("Item ",counter2, " was ",item_name[counter2], " and cost ",item_vat[counter2], ".",sep = '')
- print("The VAT was ",item_vat_num[counter2], "." ,sep = '')
- counter2 = counter2 + 1
- #use loyalty discount
- print("You got a discount on ",item_name[random_num], " and ",item_name[random_num2]," for 10% off thanks to a loyalty reward.",sep = '')
- discount_a = item_price[random_num] * 0.9
- discount_b = item_price[random_num2] * 0.9
- print(item_name[random_num]," now costs ",discount_a," and ",item_name[random_num2]," now costs ",discount_b,"." ,sep = '')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement