Price List Python Code

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

7/20/22, 3:31 AM Copy of Organizing the Price List Output - Colaboratory

Ques:01

# Setup price list

Price_list = ["01", "Banana", 5.00, "unit", "02", "Mango", 20.00, "kg", "03", "Apple", 15.00, 
              25.00, "unit", "05", "Guava", 15.00, "kg"]

# Display the Price List

print("Price List:")

print("-----------")

print("Item no  Item name  Price")

for i in range(0, 20, 4):

    print("{0:7}  {1:9}  {2:5}".format(Price_list[i], Price_list[i + 1], Price_list[i + 2]))

print("\n")

# Ask for item to be purchased

Item = input("Which item do you want to buy?: ")

Item_index = Price_list.index(Item) 

Price_index = Item_index + 1

Price = Price_list[Price_index]

Unit_index = Item_index + 2

Unit = Price_list[Unit_index]

if Unit == "unit":

    Amount = int(input("How many {0}: ".format(Item)))

elif Unit == "kg":

    Amount = float(input("Weight of {0}: ".format(Item)))

print(Amount) 

if Amount > 1:

    Unit = Unit + "s"

Amount_price = Price * Amount

VAT = Amount_price * .1

Total = Amount_price + VAT

print("\n")

print("{0} {1} of {2} will cost {3:.2f} taka".format(Amount, Unit, Item, Amount_price))

print("VAT (10%)   = {0:20.2f} taka".format(VAT))

https://colab.research.google.com/drive/1RjAbTCV6z5uwTi0xgk3NwsMxq7nEYxCW#scrollTo=8_TN5e0cRZRf&printMode=true 1/4
7/20/22, 3:31 AM Copy of Organizing the Price List Output - Colaboratory

print("Total price = {0:20.2f} taka".format(Total))

Price List:

-----------

Item no Item name Price

01 Banana 5.0

02 Mango 20.0

03 Apple 15.0

04 Papaya 25.0

05 Guava 15.0

Which item do you want to buy?: Guava

Weight of Guava: 10

10.0

10.0 kgs of Guava will cost 150.00 taka

VAT (10%) = 15.00 taka

Total price = 165.00 taka

Ques:02

Wrong spelling

# Setup price list
Price_list = ["01", "Banana", 5.00, "unit", "02", "Mango", 20.00, "kg", "03", "Apple", 15.00, 
              25.00, "unit", "05", "Guava", 15.00, "kg"]

# Display the Price List
print("Price List:")
print("-----------")
print("Item no  Item name  Price")
for i in range(0, 20, 4):
    print("{0:7}  {1:9}  {2:5}".format(Price_list[i], Price_list[i + 1], Price_list[i + 2]))
print("\n")

Item = input("Which item do you want to buy?: ")
if Item in Price_list:
 
 Item_index = Price_list.index(Item)
 Price_index = Item_index + 1
 Price = Price_list[Price_index]
 
 
 Unit_index = Item_index + 2
 Unit = Price_list[Unit_index]

https://colab.research.google.com/drive/1RjAbTCV6z5uwTi0xgk3NwsMxq7nEYxCW#scrollTo=8_TN5e0cRZRf&printMode=true 2/4
7/20/22, 3:31 AM Copy of Organizing the Price List Output - Colaboratory
 
 
 if Unit == "unit":
     Amount = int(input("How many {0}: ".format(Item)))
 elif Unit == "kg":
     Amount = float(input("Weight of {0}: ".format(Item)))
 
 print(Amount)  
 
 
 if Amount > 1:
     Unit = Unit + "s"
 
 
 Amount_price = Price * Amount
 VAT = Amount_price * .1
 Total = Amount_price + VAT
 print("\n")
 

 print("{0} {1} of {2} will cost {3:.2f} taka".format(Amount, Unit, Item, Amount_price))
 print("VAT (10%)   = {0:20.2f} taka".format(VAT))
 print("Total price = {0:20.2f} taka".format(Total))
else:
  print("No Item")

Price List:

-----------

Item no Item name Price

01 Banana 5.0

02 Mango 20.0

03 Apple 15.0

04 Papaya 25.0

05 Guava 15.0

Which item do you want to buy?: Guv

No Item

https://colab.research.google.com/drive/1RjAbTCV6z5uwTi0xgk3NwsMxq7nEYxCW#scrollTo=8_TN5e0cRZRf&printMode=true 3/4
7/20/22, 3:31 AM Copy of Organizing the Price List Output - Colaboratory

check 7s completed at 3:30 AM

https://colab.research.google.com/drive/1RjAbTCV6z5uwTi0xgk3NwsMxq7nEYxCW#scrollTo=8_TN5e0cRZRf&printMode=true 4/4

You might also like