O Level Exam : Practical Question
📝 HTML
🎨 CSS
⚡ Java Script
import pickle filename = "items.dat" n = int(input("Enter the number of records: ")) file = open(filename, "wb") for i in range(n): print("\nEnter Details of Item", i + 1) item_no = int(input("Enter Item No: ")) item_name = input("Enter Item Name: ") quantity = int(input("Enter Quantity: ")) price = float(input("Enter Price per Item: ")) record = [item_no, item_name, quantity, price] pickle.dump(record, file) file.close() # Reading Records from Binary File print("\n----- ITEM DETAILS -----") file = open(filename, "rb") try: while True: record = pickle.load(file) amount = record[2] * record[3] print("\nItem No :", record[0]) print("Item Name :", record[1]) print("Quantity :", record[2]) print("Price per Item:", record[3]) print("Amount :", amount) except EOFError: file.close()
▶ Run Code
🖥 Output: