Page 49 - ipp11
P. 49

33.  Predict the output of the following code:                                                  [4]

               colors = ["Red", "Blue", "Green", "Blue", "Orange"]
               colors.append("Yellow")
               colors.insert(2, "Purple")
               colors.remove("Green")
               print(colors)
           Ans.  ['Red', 'Blue', 'Purple', 'Black', 'Orange', 'Yellow']
            34.  Write a Python program to input employee details (EmpID, Name, Salary) and store them in a dictionary. The
               program should allow the user to input employees’ details and then search and display the information based
               on the EmpID entered by the employee.                                                        [4]
           Ans.  employees = {}
               n = int(input("Enter number of employees: "))
               for i in range(n):
                     emp_id = input("Enter EmpID: ")
                     name = input("Enter Name: ")
                     salary = float(input("Enter Salary: "))
                     employees[emp_id] = {"Name": name, "Salary": salary}
               search_id = input("Enter EmpID to search: ")
               if search_id in employees:
                     print("Employee found:", employees[search_id])
               else:
                     print("Employee not found.")
            35.  Consider the following tables.                                                             [4]
                                                      Table: Teachers

                          TeacherID               Name                 Subject               Salary
                             2101         Meenal Roy            English                      60000
                             2102         Rekha Verma           Computer                     72000
                             2103         Nishika Kapoor        Maths                        67000
                             2104         Disha Kumar           Science                      58000
                             2105         Anil Singh            Computer                     75000
                                                     Table: Trainings
                          TrainingID          TrainingName           TeacherID            TrainingDate
                             1301         Python Workshop               2102               2025-05-10
                             1302         Math Pedagogy                 2103               2025-04-15
                             1303         Science Fair Prep             2104               2025-03-25
                             1304         English Enrichment            2101               2025-01-10
                             1305         Robotics Training             2105               2025-02-05
                Write SQL queries for (a) and (b) and write the output for (c) to (e) on the basis of tables Teachers and Trainings.
                (a)  Write a query to add a column Age in the table Teachers.
                (b)  Write a query to display the details of teachers whose name contains the letter ‘i’.
                (c)  SELECT * FROM Teachers WHERE Subject = "Computer" AND Salary > 65000;
                (d)  SELECT Name, Salary FROM Teachers WHERE TeacherID between 2101 and 2104;
                (e)  SELECT  TrainingName,  TrainingDate FROM  Trainings  WHERE  TrainingDate  >
                   '2025-02-01';




                                                              M.19
   44   45   46   47   48   49   50   51   52   53   54