Advertisements
Advertisements
Question
The record of a student (Name, Roll No., Marks in five subjects and percentage of marks) is stored in the following list: stRecord = ['Raman', 'A-36', [56, 98, 99, 72, 69], 78.8]
Write Python statements to retrieve the following information from the list stRecord.
- Percentage of the student
- Marks in the fifth subject
- Maximum marks of the student
- Roll no. of the student
- Change the name of the student from ‘Raman’ to ‘Raghav’.
Advertisements
Solution
| List Name | Name | Roll No. | Marks in 5 Subjects | Percentage |
| stRecord | Raman | A-36 | [56, 98, 99, 72, 69] | 78.8 |
| Index | 0 | 1 | 2
[0, 1, 2, 3, 4] index of the list at index 2 |
3 |
Here, we can see that the 'name' is stored at index 0, 'roll no' at index 1, 'marks of the 5 subjects' is stored at index 2 in a list that contains 5 elements, and 'percentage' at index 3.
- Percentage: stRecord[3]
- Marks in 5th Subject: stRecord[2][4]
- Maximum Marks of the Student: max(stRecord[2])
- Roll no. of the student: stRecord[1]
- Change the name from Raman to Raghav: stRecord[0] = "Raghav".
APPEARS IN
RELATED QUESTIONS
What will be the output of the following code segment:
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[3:]
print(myList)What will be the output of the following code segment:
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:5]
print(myList)What will be the output of the following code segment:
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[::2]
print(myList)Write a program to read elements of a list.
The program should ask for the position of the element to be deleted from the list. Write a function to delete the element at the desired position in the list.
Write a program to read elements of a list.
The program should ask for the value of the element to be deleted from the list. Write a function to delete the element of this value from the list.
