Write a python program to input names of 'n' customers and their details like items bought cost and phone number store it in a dictionary and display all the details in a tabular form
Answers
Answer:
# Define the dictionary
dict ={}
# Insert data into dicitonary
dict1 = {1: ["Samuel", 21, 'Data Structures'],
2: ["Richie", 20, 'Machine Learning'],
3: ["Lauren", 21, 'OOPS with java'],
}
# Print the names of the columns.
print ("{:<10} {:<10} {:<10}".format('NAME', 'AGE', 'COURSE'))
# print each data item.
for key, value in dict1.items():
name, age, course = value
print ("{:<10} {:<10} {:<10}"
n = int(input("Enter the number of customers to be entered: "))
cst_dict = dict()
print()
for i in range(n):
x = input("Enter the name of the customer: ")
y = input("Enter the product purchased: ")
z = input("Enter the phone number of the customer: ")
cst_dict[x] = y, z
print()
print()
print("This is your given dictionary: ")
print("Name", "\t\t\t", "Product Purchased", "\t\t\t", "Phone Number")
for i in cst_dict:
print(i, "\t\t\t", cst_dict[i][0], "\t\t\t\t", cst_dict[i][1])