Write a program to accept and store the details of 25 products manufactured by a firm. The details are pc(Product Code), name(Name of the Product), yom (year of Manufacturing) and mrp(Maximum retail price). Print the details of all products in a tabular format. Also accept the product code from the console and print all the details of that particular product on the screen. Print appropriate message if the product code does not exist.
Answers
The following codes have been written using Python.
prod_dict = dict()
for i in range(2):
pc = input("Enter the product code: ")
name = input("Enter the name of the product: ")
yom = input("Enter the year of manufacturing: ")
mrp = input("Enter the maximum retail price: ")
prod_dict[pc] = name, yom, mrp
print()
print()print("Your given details: ")
print()
print("Product Code", "\t\t", "Name", "\t\t", "YOM", "\t\t", "MRP")
print()
for i in prod_dict:
print(i, "\t\t\t", prod_dict[i][0], "\t\t\t", prod_dict[i][1], "\t\t\t", prod_dict[i][2])
print()
dpc = input("Enter the Product Code of the desired product to be viewed: ")
if dpc in prod_dict:
print("PC: ", dpc)
print("Name: ", prod_dict[dpc][0])
print("YOM: ", prod_dict[dpc][1])
print("MRP: ", prod_dict[dpc][2])
else:
print("Invalid Code!")
Answer:
Here ur answer❤
Explanation:
The following codes have been written using Python.
prod_dict = dict()
for i in range(2):
pc = input("Enter the product code: ")
name = input("Enter the name of the product: ")
yom = input("Enter the year of manufacturing: ")
mrp = input("Enter the maximum retail price: ")
prod_dict[pc] = name, yom, mrp
her
print()
print()print("Your given details: ")
print()
print("Product Code", "\t\t", "Name", "\t\t", "YOM", "\t\t", "MRP")
print()
for i in prod_dict:
print(i, "\t\t\t", prod_dict[i][0], "\t\t\t", prod_dict[i][1], "\t\t\t", prod_dict[i][2])
print()
dpc = input("Enter the Product Code of the desired product to be viewed: ")
if dpc in prod_dict:
print("PC: ", dpc)
print("Name: ", prod_dict[dpc][0])
print("YOM: ", prod_dict[dpc][1])
print("MRP: ", prod_dict[dpc][2])
else:
print("Invalid Code!")