Using binary search approach, write a python function named update_record, which takes the following inputs: 1: students_records – Nested List of Tuples. Each tuple of the list represents student's data. 2: ID – An ID of a student whose data has to be updated 3: record_title – type of data that has to be updated 4: data – A new data that should replace record_title data and update the record of students' data associated to specific ID. If ID is given as the data to be updated, then return a message that ID cannot be updated. If ID is not found in students_records, then return a message that Record not found. NOTE: The type of record_title input can be "ID", "Email", "Mid1" or "Mid2". Please use the same spelling for these types in your code, because the same have been used in test cases. Test cases are attached below: student_records = '[("aa02822", "ea02822", 80, 65),("ea02822", "ea02822@st.habib.edu.pk", 80, 65),("fa08877", "fa08877@st.habib.edu.pk", 66, 67),("gh04588", "gh04588@st.habib.edu.pk", 33, 50)]' >>> update_record(students_records, "aa02822", "ID", "aa02456") ID cannot be updated >>> update_record(students_records, "aa02822", "Email", "aa02822@st.habib.edu.pk") [("aa02822", "aa02822@st.habib.edu.pk", 80, 65), ("ea02822", "ea02822@st.habib.edu.pk", 80, 65), ("fa08877", "fa08877@st.habib.edu.pk", 66, 67), ("gh04588", "gh04588@st.habib.edu.pk", 33, 50)] >>> update_record(students_records, 'f08877', "Mid2", 50) Record not found
Using binary search approach, write a python function named update_record, which takes the following inputs:
1: students_records – Nested List of Tuples. Each tuple of the list represents student's data.
2: ID – An ID of a student whose data has to be updated
3: record_title – type of data that has to be updated
4: data – A new data that should replace record_title data and update the record of students' data associated to specific ID.
If ID is given as the data to be updated, then return a message that ID cannot be updated.
If ID is not found in students_records, then return a message that Record not found.
NOTE: The type of record_title input can be "ID", "Email", "Mid1" or "Mid2". Please use the same spelling for these types in your code, because the same have been used in test cases.
Test cases are attached below:
student_records = '[("aa02822", "ea02822", 80, 65),("ea02822", "ea02822@st.habib.edu.pk", 80, 65),("fa08877", "fa08877@st.habib.edu.pk", 66, 67),("gh04588", "gh04588@st.habib.edu.pk", 33, 50)]'
>>> update_record(students_records, "aa02822", "ID", "aa02456")
ID cannot be updated
>>> update_record(students_records, "aa02822", "Email", "aa02822@st.habib.edu.pk")
[("aa02822", "aa02822@st.habib.edu.pk", 80, 65), ("ea02822", "ea02822@st.habib.edu.pk", 80, 65), ("fa08877", "fa08877@st.habib.edu.pk", 66, 67), ("gh04588", "gh04588@st.habib.edu.pk", 33, 50)]
>>> update_record(students_records, 'f08877', "Mid2", 50)
Record not found
Step by step
Solved in 2 steps