हिंदी

Mr. Ravi, a manager at a tech company, needs to maintain records of employees. Each record should include: Employee ID, Employee_Name, Department and Salary. - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

Mr. Ravi, a manager at a tech company, needs to maintain records of employees. Each record should include: Employee ID, Employee_Name, Department and Salary. Write the Python functions to update the salary of employees in the "IT" department to 200000.

कोड लेखन
Advertisements

उत्तर

def update_data():
   updated = False
   employees = []
   with open("emp.dat",'rb') as file:
     try:
       while True:
         employee = pickle.load(file)
         if employee[2] == "IT":
            employee[3] = 200000
            updated = True
         employees.append(employee)
     except EOFError:
       pass
    with open("emp.dat",'wb') as file:
     for employee in employees:
       pickle.dump(employee, file)
    if updated:
     print("Salaries updated for IT department.")
    else:
     print("No employee found in the IT department.")
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2025-2026 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×