Advertisement
Anonymous0069

School_Database_project

Jan 2nd, 2023 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.22 KB | Source Code | 0 0
  1. print("Students's Database")
  2.  
  3. main_dic = {}
  4.  
  5.  
  6. print('''Enter the corresponding number of the task you want to perform:
  7. 1. Adding records
  8. 2. Search a record
  9. 3. Delete a record
  10. 4. Update a record:''')
  11.  
  12. ops = int(input())
  13. if ops == 1:
  14.     no = int(input("Enter the number of records you want to enter:"))
  15.     no += 1
  16.  
  17.     for i in range(1,no):
  18.    
  19.         name = input("Enter the name:")
  20.         clas = input("Enter the class:")
  21.         Roll_no = int(input("Enter the Roll no:"))
  22.         Fee_status = input("Enter the Fee status(Cleared/Pending):")
  23.  
  24.         amt_fees = 0
  25.        
  26.         if Fee_status == 'Pending' or Fee_status == 'pending':
  27.             amt_fees = int(input("Amount of fees pending:"))
  28.  
  29.        
  30.         new_dic = {}
  31.         new_dic.setdefault(Roll_no,[name,clas,Fee_status,amt_fees])
  32.         print("Record updated!")
  33.         main_dic.update(new_dic)
  34.         print(main_dic)
  35.  
  36.     print("Any new operation you want to proceed with? (Yes/No)")
  37.     rep = input()
  38.  
  39.     if rep == 'Yes':
  40.         print('''Enter the corresponding number of the task you want to perform:
  41. 1. Adding records
  42. 2. Search a record
  43. 3. Delete a record
  44. 4. Update a record:''')
  45.         arg = int(input())
  46.         ops = arg
  47.  
  48.     else:
  49.         print("Tasks accomplished!")
  50.  
  51. if ops == 2:
  52.  
  53.     search_roll = int(input("Enter the Roll no. of the student:"))
  54.    
  55.     if search_roll in main_dic:
  56.         print("Here's the info:", main_dic.get(search_roll))
  57.  
  58.     else:
  59.         print("Invalid argument!")
  60.  
  61.     print("Any new operation you want to proceed with? (Yes/No)")
  62.     rep = input()
  63.  
  64.     if rep == 'Yes':
  65.         print('''Enter the corresponding number of the task you want to perform:
  66. 1. Adding records
  67. 2. Search a record
  68. 3. Delete a record
  69. 4. Update a record:''')
  70.  
  71.         arg = int(input())
  72.         ops = arg
  73.  
  74.     else:
  75.         print("Tasks accomplished!")
  76.  
  77.  
  78. if ops == 3:
  79.     print("Available database:", main_dic)
  80.  
  81.     del_rec = int(input("Enter the number of records to be deleted:"))
  82.  
  83.     for i in range(del_rec):
  84.         del_key = int(input("Enter the key of the record you want to delete:"))
  85.         main_dic.pop(del_key)
  86.         print("Record deleted!")
  87.         print("The updated database:", main_dic)
  88.  
  89.     print("Any new operation you want to proceed with? (Yes/No)")
  90.     rep = input()
  91.  
  92.     if rep == 'Yes':
  93.         print('''Enter the corresponding number of the task you want to perform:
  94. 1. Adding records
  95. 2. Search a record
  96. 3. Delete a record
  97. 4. Update a record:''')
  98.  
  99.         arg = int(input())
  100.         ops = arg
  101.            
  102.     else:
  103.         print("Tasks accomplished!")            
  104.            
  105. if ops == 4:
  106.  
  107.     print("Available database is:", main_dic)
  108.     print('''Enter the number of the corresponding task to be performed:
  109.    1. Append a record
  110.    2. Change the data of a particular field of existing record''')
  111.  
  112.     det = int(input())
  113.  
  114.     if det == 1:
  115.         print("Format to enter data: [Roll_No, Name, Class, Fee Status, Amount of Fees pending]")
  116.         app = eval(input("Enter the data of the student (in list):"))
  117.         a,b,c,d,e = app
  118.         new_rec = {a:[b,c,d,e]}
  119.         main_dic.update(new_rec)
  120.         print("Database updated!")
  121.         print(main_dic)
  122.  
  123.         print("Any new operation you want to proceed with? (Yes/No)")
  124.         rep = input()
  125.         if rep == 'Yes':
  126.             print('''Enter the corresponding number of the task you want to perform:
  127. 1. Adding records
  128. 2. Search a record
  129. 3. Delete a record
  130. 4. Update a record:''')
  131.  
  132.             arg = int(input())
  133.             ops = arg
  134.  
  135.         else:
  136.             print("Tasks accomplished!")
  137.  
  138. if ops == 4:
  139.  
  140.     print("Available database is:", main_dic)
  141.     print('''Enter the number of the corresponding task to be performed:
  142.    1. Append a record
  143.    2. Change the data of a particular field of existing record''')
  144.  
  145.     det = int(input())
  146.  
  147.     if det == 2:
  148.         up_rec = int(input("Enter the key of the record to be updated:"))
  149.         up_field = int(input('''Enter the corresponding number for the field to be updated:
  150.                            0. Name
  151.                            1. Class
  152.                            2. Fee Status
  153.                            3. Amount of fees pending:'''))
  154.         if up_field == 2:
  155.            
  156.             up_dat = input("Enter the new status:")
  157.             up_amt = int(input("Enter the amount of pending fee:"))
  158.             main_dic[up_rec][up_field] = up_dat
  159.             main_dic[up_rec][3] = up_amt
  160.             print("Record updated!")
  161.             print(main_dic)
  162.  
  163.  
  164.         else:
  165.  
  166.             up_dat = input("Enter the new data:")
  167.             main_dic[up_rec][up_field] = up_dat
  168.             print("Record updated!")
  169.             print(main_dic)
  170.  
  171.         print("Any new operation you want to proceed with? (Yes/No)")
  172.         rep = input()
  173.    
  174.         if rep == 'Yes':
  175.             print('''Enter the corresponding number of the task you want to perform:
  176. 1. Adding records
  177. 2. Search a record
  178. 3. Delete a record
  179. 4. Update a record:''')
  180.  
  181.             arg = int(input())
  182.             ops = arg
  183.  
  184.         else:
  185.             print("Tasks accomplished!")
  186.  
  187.  
  188. #[10, 'Ram', 'XI B', 'Cleared', 0]
  189. #[15, 'Rohan', 'XII B', 'Pending', 700]
  190.  
  191.  
  192.  
  193.        
  194.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement