• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 21st, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import random
2.
3. #declare variables
4. item_name = [""] * 30
5. item_price = [0.0] * 30
6. item_vat = [0.0] * 30
7. item_vat_num = [0.0] * 30
8. anymore = "YES"
9. VAT = 0.8
10. VAT2 = 0.2
11. counter = 1
12. counter2 = 1
13. num_item = 1
14. random_num = 0
15. random_num2 = 0
16. discount_a = 0.0
17. discont_b = 0.0
18.
19. #get items and calculate VAT
20. while anymore.upper() == "YES":
21.     print("Please enter the name of item ",counter,".",sep = '')
22.     item_name[counter] = str(input())
23.     print("Please enter the price of ",item_name[counter],".",sep = '')
24.     item_price[counter] = float(input())
25.     item_vat[counter] = item_price[counter] * VAT
26.     item_vat_num[counter] = item_price[counter] * VAT2
27.     counter = counter + 1
28.     num_item = num_item + 1
29.     print("Would you like to select another item?")
30.     anymore = str(input())
31.     if anymore.upper() == "NO":
32.         anymore = "no"
33.
34. #find random discount
35. random_num = random.randint(1,(num_item - 1))
36. random_num2 = random.randint(1,(num_item - 1))
37. if random_num == random_num2:
38.     random_num2 == random.randint(1(num_item - 1))
39.
40.
41. #display items
42. for loops in range(1,num_item):
43.     print("Item ",counter2, " was ",item_name[counter2], " and cost ",item_vat[counter2], ".",sep = '')
44.     print("The VAT was ",item_vat_num[counter2], "." ,sep = '')
45.     counter2 = counter2 + 1
46.
47. #use loyalty discount
48. print("You got a discount on ",item_name[random_num], " and ",item_name[random_num2]," for 10% off thanks to a loyalty reward.",sep = '')
49. discount_a = item_price[random_num] * 0.9
50. discount_b = item_price[random_num2] * 0.9
51. print(item_name[random_num]," now costs ",discount_a," and ",item_name[random_num2]," now costs ",discount_b,"." ,sep = '')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top