Computer Science
Write a Python program to input names of 'n' customers and their details like items bought, cost and phone number, etc., store them in a dictionary and display all the details in a tabular form.
Answer
n = int(input("Enter the number of customers: "))
customer_data = {}
for i in range(n):
name = input("Enter customer name: ")
items_bought = input("Enter items bought: ")
cost = float(input("Enter cost: "))
phone_number = int(input("Enter phone number: "))
customer_data[name] = {
'Items Bought': items_bought,
'Cost': cost,
'Phone Number': phone_number
}
print("Customer Details:")
print("Name\t\tItems Bought\t\tCost\t\tPhone Number")
for name, details in customer_data.items():
print(name, "\t\t", details['Items Bought'], "\t\t", details['Cost'], "\t\t", details['Phone Number'])
Output
Enter the number of customers: 4
Enter customer name: Sakshi
Enter items bought: Chocolate, Icecream
Enter cost: 200
Enter phone number: 9876354678
Enter customer name: Shashank
Enter items bought: Biscuits, Maggie, Soup
Enter cost: 450
Enter phone number: 8976346378
Enter customer name: Saanvi
Enter items bought: Veggies, Coffee
Enter cost: 300
Enter phone number: 8794653923
Enter customer name: Shivank
Enter items bought: Door mat, Bottles, Boxes
Enter cost: 600
Enter phone number: 6737486827
Customer Details:
Name Items Bought Cost Phone Number
Sakshi Chocolate, Icecream 200.0 9876354678
Shashank Biscuits, Maggie, Soup 450.0 8976346378
Saanvi Veggies, Coffee 300.0 8794653923
Shivank Door mat, Bottles, Boxes 600.0 6737486827
Related Questions
Write a Python program to input 'n' classes and names of class teachers to store them in a dictionary and display the same. Also accept a particular class from the user and display the name of the class teacher of that class.
Write a program to store student names and their percentage in a dictionary and delete a particular student name from the dictionary. Also display the dictionary after deletion.
Write a Python program to capitalize first and last letters of each word of a given string.
Write a Python program to remove duplicate characters of a given string.