Home / Expert Answers / Computer Science / you-have-a-simple-record-of-some-students-stored-in-a-list-the-format-of-the-list-is-as-follows-pa868

(Solved): You have a simple record of some students stored in a list. The format of the list is as follows: ...



You have a simple record of some students stored in a list. The format of the list is as follows: [  Student #1 Name , stud1 def swap_records (student_records, name1, name2):
2 return [] # DELETE THIS LINE and start coding here.
3
4
5 # Test cases

You have a simple record of some students stored in a list. The format of the list is as follows: [ ' Student #1 Name' , student #1 Age, .... ]. Each student's name is immediately followed by that student's age. For example, a five-student record could be something like: ['John', 15, 'Singed', 14, 'Hana', 16, 'Zekan', 13, 'Ronald', 16] You are tasked with swapping two students' records. Complete the function swap_record, which takes in three arguments: 1. student_records, which holds the records of the students as described above 2. name1, a student's name 3. name2, a different student's name the student record list. In this case, the original list remains unchanged. You may assume that every name in student_records is unique and that name1 \( != \) name2. 1 def swap_records (student_records, name1, name2): 2 return [] # DELETE THIS LINE and start coding here. 3 4 5 # Test cases 6 stus \( 1=[ \) 'John', 15, 'Singed', 14,' 'Hana', 16, 'Zekan', 13] 7 swap_records (stus1, 'John', 'Singed') 8 print(stus 1\( ) \) 10 stus \( 2= \) ' 'John', 15, 'Singed', 14, 'Hana', 16, 'Zekan', 13] 11 swap_records (stus2, 'Zekan', 'John') 12 print(stus2) 13 14 stus \( 3=\left[\mathrm{Zac}^{\prime}, 10\right. \), 'Yell', 9 \( ] \) 15 swap_records (stus3, 'Zac', 'Yell') 16 print(stus 3 ) 17 18 stus4 = ['Alfred', 19, 'John', 15, 'Singed', 14, 'Nate', 14, 'Hana', 16, 'Zekan 19 swap_records(stus4, 'Hana', 'John') 20 print(stus 4 ) 21 22 stus5 \( =[ \) 'John', 15, 'Singed', 14, 'Hana', 16, 'Zekan', 13] 23 swap_records (stus5, 'Bob', 'Singed') 24 print(stus5) 25 26 stus6 \( =[ \) 'Hana', 15, 'Singed', 14, 'Hana', 16, 'Zekan', 13] 27 swap_records(stus6, 'Bob', 'Francis') 28 print(stus 6 )


We have an Answer from Expert

View Expert Answer

Expert Answer


Here is the code in java Code: #function takes the student_records and name1 and name2 #swap their names and ages if both are present in the list def
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe