0% found this document useful (0 votes)
5 views

Assignment Second Version

Uploaded by

JS K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Assignment Second Version

Uploaded by

JS K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

products = []

for product_number in range (1,4):

name = str(input("Please enter the name of the product:"))

quantity = int(input("Please enter the quantity of the product:"))

price = float(input("Please enter the price of the the product(RM):"))

sales = int(input("Please enter the sales of the the product(how many items were sold):"))

revenue = sales * price

remaining_quantity = quantity - sales

product_info = {

"Name": name,

"Quantity": quantity,

"Price": price,

"Sales": sales,

"Revenue": revenue,

"Remaining quantity": remaining_quantity

products.append(product_info)

for product_number in range(len(products)):

print ("\nProduct " + str(product_number + 1) + " Information:")

for attribute, value in products[product_number].items():

print (str(attribute) + ":" + str(value))

total_revenue = sum(product["Revenue"] for product in products)

print("\nThe total revenue generate from all sales is:", total_revenue)

import matplotlib.pyplot as plt

products_name = [product["Name"]for product in products]

products_remaining_quantity = [product["Remaining quantity"]for product in products]


plt.bar(products_name, products_remaining_quantity, color = 'blue')

plt.xlabel("Name of Products")

plt.ylabel("Remaining Quantity of Products")

plt.title("Remaining Quantity of Products")

You might also like