Computer Science, asked by sameer4528, 5 months ago

The class teacher of the class has stored the name of all students in her cans in the list stud let. Write the statement to 1. Sort the student st. .
2 Add a new student to the list t
3. Remove a student from the list .
4. Check whether me students Ram's present in the ist or nat 5. Add the surname "Kumar to the student at index 5 in the list​

Answers

Answered by Equestriadash
11

1. To sort the list.

  • student_list.sorted()

2. To add a new student to the list.

  • student_list.append(‎<new_student_name>‎)

3. To remove a student from the list.

  • student_list.pop(‎<index_position>‎) #pop can be used if you're aware of the index position of the student in the list.
  • student_list.remove(‎<student_name>‎) #remove can be used if you're aware of the student's name.
  • del student_list[‎<index_position>‎] #del can be used using the index position.

4. To check if a student named 'Ram' is there in the list or not.

  • 'Ram' in student_list

5. To add the surname 'Kumar' to the student at index position 5.

  • l[5] = l[5] + " Kumar" #this has been done using string concatenation.
Similar questions