Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Students's Database")
- main_dic = {}
- print('''Enter the corresponding number of the task you want to perform:
- 1. Adding records
- 2. Search a record
- 3. Delete a record
- 4. Update a record:''')
- ops = int(input())
- if ops == 1:
- no = int(input("Enter the number of records you want to enter:"))
- no += 1
- for i in range(1,no):
- name = input("Enter the name:")
- clas = input("Enter the class:")
- Roll_no = int(input("Enter the Roll no:"))
- Fee_status = input("Enter the Fee status(Cleared/Pending):")
- amt_fees = 0
- if Fee_status == 'Pending' or Fee_status == 'pending':
- amt_fees = int(input("Amount of fees pending:"))
- new_dic = {}
- new_dic.setdefault(Roll_no,[name,clas,Fee_status,amt_fees])
- print("Record updated!")
- main_dic.update(new_dic)
- print(main_dic)
- print("Any new operation you want to proceed with? (Yes/No)")
- rep = input()
- if rep == 'Yes':
- print('''Enter the corresponding number of the task you want to perform:
- 1. Adding records
- 2. Search a record
- 3. Delete a record
- 4. Update a record:''')
- arg = int(input())
- ops = arg
- else:
- print("Tasks accomplished!")
- if ops == 2:
- search_roll = int(input("Enter the Roll no. of the student:"))
- if search_roll in main_dic:
- print("Here's the info:", main_dic.get(search_roll))
- else:
- print("Invalid argument!")
- print("Any new operation you want to proceed with? (Yes/No)")
- rep = input()
- if rep == 'Yes':
- print('''Enter the corresponding number of the task you want to perform:
- 1. Adding records
- 2. Search a record
- 3. Delete a record
- 4. Update a record:''')
- arg = int(input())
- ops = arg
- else:
- print("Tasks accomplished!")
- if ops == 3:
- print("Available database:", main_dic)
- del_rec = int(input("Enter the number of records to be deleted:"))
- for i in range(del_rec):
- del_key = int(input("Enter the key of the record you want to delete:"))
- main_dic.pop(del_key)
- print("Record deleted!")
- print("The updated database:", main_dic)
- print("Any new operation you want to proceed with? (Yes/No)")
- rep = input()
- if rep == 'Yes':
- print('''Enter the corresponding number of the task you want to perform:
- 1. Adding records
- 2. Search a record
- 3. Delete a record
- 4. Update a record:''')
- arg = int(input())
- ops = arg
- else:
- print("Tasks accomplished!")
- if ops == 4:
- print("Available database is:", main_dic)
- print('''Enter the number of the corresponding task to be performed:
- 1. Append a record
- 2. Change the data of a particular field of existing record''')
- det = int(input())
- if det == 1:
- print("Format to enter data: [Roll_No, Name, Class, Fee Status, Amount of Fees pending]")
- app = eval(input("Enter the data of the student (in list):"))
- a,b,c,d,e = app
- new_rec = {a:[b,c,d,e]}
- main_dic.update(new_rec)
- print("Database updated!")
- print(main_dic)
- print("Any new operation you want to proceed with? (Yes/No)")
- rep = input()
- if rep == 'Yes':
- print('''Enter the corresponding number of the task you want to perform:
- 1. Adding records
- 2. Search a record
- 3. Delete a record
- 4. Update a record:''')
- arg = int(input())
- ops = arg
- else:
- print("Tasks accomplished!")
- if ops == 4:
- print("Available database is:", main_dic)
- print('''Enter the number of the corresponding task to be performed:
- 1. Append a record
- 2. Change the data of a particular field of existing record''')
- det = int(input())
- if det == 2:
- up_rec = int(input("Enter the key of the record to be updated:"))
- up_field = int(input('''Enter the corresponding number for the field to be updated:
- 0. Name
- 1. Class
- 2. Fee Status
- 3. Amount of fees pending:'''))
- if up_field == 2:
- up_dat = input("Enter the new status:")
- up_amt = int(input("Enter the amount of pending fee:"))
- main_dic[up_rec][up_field] = up_dat
- main_dic[up_rec][3] = up_amt
- print("Record updated!")
- print(main_dic)
- else:
- up_dat = input("Enter the new data:")
- main_dic[up_rec][up_field] = up_dat
- print("Record updated!")
- print(main_dic)
- print("Any new operation you want to proceed with? (Yes/No)")
- rep = input()
- if rep == 'Yes':
- print('''Enter the corresponding number of the task you want to perform:
- 1. Adding records
- 2. Search a record
- 3. Delete a record
- 4. Update a record:''')
- arg = int(input())
- ops = arg
- else:
- print("Tasks accomplished!")
- #[10, 'Ram', 'XI B', 'Cleared', 0]
- #[15, 'Rohan', 'XII B', 'Pending', 700]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement