Python
- Description
- Curriculum
- Reviews
- Grade
-
55What is a List?
-
56Common List Functions & Methods
-
57Procedure (Step-by-Step With Explanation)
Procedure (Step-by-Step With Explanation)
Step 1: Create Python File
Create folder:
python_day8
Create file:day8.pyStep 2: Create and Display List
subjects = ["Maths", "Physics", "Chemistry"]print(subjects)Explanation:
Stores multiple subjects in one variable.Step 3: Access and Modify List Elements
print(subjects[0])
subjects[1] = "Biology"
print(subjects)Step 4: Add Elements
subjects.append("Computer")
subjects.insert(1, "English")
print(subjects)Step 5: Remove Elements
subjects.remove("Maths")
subjects.pop()
print(subjects)Step 6: Sorting and Iteration
marks = [88, 72, 95, 60]
marks.sort()for m in marks:
print(m)Step 7: Execute the Program
Run:
python day8.py
Sample Output
['Maths', 'Physics', 'Chemistry']
Maths
['Maths', 'Biology', 'Chemistry']
['Maths', 'English', 'Biology', 'Chemistry', 'Computer']
['English', 'Biology', 'Chemistry']
60
72
88
95 -
58Additional Programs
-
59Quiz
-
60Assignment