0% found this document useful (0 votes)
15 views10 pages

Python List Operations

The document provides an overview of basic Python list operations suitable for 9th/10th graders, including methods such as append, extend, insert, remove, pop, sort, and reverse. Each operation is illustrated with example code and print statements to demonstrate the results. This serves as a practical guide for students learning to manipulate lists in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views10 pages

Python List Operations

The document provides an overview of basic Python list operations suitable for 9th/10th graders, including methods such as append, extend, insert, remove, pop, sort, and reverse. Each operation is illustrated with example code and print statements to demonstrate the results. This serves as a practical guide for students learning to manipulate lists in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Python List Operations

This document contains basic Python list operations for 9th/10th graders, including append, extend,

insert, remove, pop, sort, reverse, and more.


Appending an Element

fruits = ["apple", "banana", "cherry"]

fruits.append("orange")

print(fruits)
Extending a List

numbers = [1, 2, 3]

numbers.extend([4, 5, 6])

print(numbers)
Inserting an Element

colors = ["red", "blue", "green"]

colors.insert(1, "yellow")

print(colors)
Removing an Element

animals = ["dog", "cat", "elephant"]

animals.remove("cat")

print(animals)
Popping an Element

students = ["John", "Mike", "Sara"]

removed_student = students.pop(1)

print(students)

print("Removed:", removed_student)
Finding Index

numbers = [10, 20, 30, 40, 50]

index = numbers.index(30)

print("Index of 30:", index)


Counting Occurrences

marks = [85, 90, 85, 80, 85]

count = marks.count(85)

print("85 appears", count, "times")


Sorting a List

ages = [25, 18, 30, 22]

ages.sort()

print("Sorted ages:", ages)


Reversing a List

letters = ["a", "b", "c", "d"]

letters.reverse()

print("Reversed list:", letters)

You might also like