Page 28 - PYTHON-12
P. 28

with open('FacultyMembers.bin', 'rb') as f:
                                          while True:
                                                try:
                                                     facultymem = pickle.load(f)
                                                     if isinstance(facultymem, list) and
                                                     len(facultymem)== 4:
                                                           if facultymem[3] > 15:
                                                                 facultymem[2] = 'Senior Faculty'
                                                     updated_faculty.append(facultymem)
                                                except EOFError:
                                                     break
                       except FileNotFoundError:
                               print("No faculty data found. Please add faculties first.")
                               return
                       with open('FacultyMembers.bin', 'wb') as f:
                               for facultymem in updated_faculty:
                                    pickle.dump(facultymem,        f)
                       print("Candidates updated to Senior Faculty where applicable.")
                       update_senior_faculty()
                   (III)  import pickle
                       def display_non_senior_faculty():
                               fm=[]
                               try:
                                    with open('FacultyMembers.bin', 'rb') as f:
                                          while True:
                                                try:
                                                     fm = pickle.load(f)
                                                     if fm[2] != 'Senior Faculty':
                                                           print("Candidate ID:", fm[0])
                                                           print("Candidate Name:" ,fm[1])
                                                           print("Designation:", fm[2])
                                                     print("Experience:" ,fm[3])
                                                     print("--------------------")
                                                except EOFError:
                                                     break
                               except FileNotFoundError:
                                            print("No  candidate data found. Please add candidates
                                          first.")
                       display_non_senior_faculty()
                37.  A  research institute, Technology Hub, is setting up a new  campus in Pune. The campus will  have  the
                   following departments: LAB, RESEARCH, ADMIN and AUDITORIUM. The distance between the departments
                   is as follows:                                                                           (5)

                                                           PUNE

                                                    LAB           RESEARCH

                                                  ADMIN         AUDITORIUM



              A.14   Computer Science–XII
   23   24   25   26   27   28   29   30   31   32   33