Program to illustrate searching of objects from an array of objects using ID in Python
Problem Description: We need to create a class to take the students information from the user and the print the object whose id matches the enter input id.
Class Used in the program:
- Class : student
- Method : getStudentInfo() : gets input of the student information from the user.
- Method : putStudentInfo() : print in student information to the screen.
- For searching, we have the inbuilt method get().
Algorithm:
- Step 1: Taking input from the user for id, name, marks of the student.
- Step 2: Print information, of the user using the putStudentInfo() method.
- Step 3: We took an id to be searched from the user. And then using get() method which will return "Not Found", if no match for the roll number is found in the object.
Program to illustrate the working of our solution
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer