0% found this document useful (0 votes)
5 views3 pages

Python Program List

The document provides a series of Python programs demonstrating basic list operations. It covers creating, modifying, accessing, and manipulating lists, including adding elements, finding lengths, and sorting. Each example includes the code and the expected output.

Uploaded by

goralsokhiya
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)
5 views3 pages

Python Program List

The document provides a series of Python programs demonstrating basic list operations. It covers creating, modifying, accessing, and manipulating lists, including adding elements, finding lengths, and sorting. Each example includes the code and the expected output.

Uploaded by

goralsokhiya
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

1.

Create a List and Display It


Program:
numbers = [10, 20, 30, 40, 50]
print(numbers)
Output:
[10, 20, 30, 40, 50]

2. Add an Element to a List


Program:
fruits = ["Apple", "Banana", "Mango"]
[Link]("Orange")
print(fruits)
Output:
['Apple', 'Banana', 'Mango', 'Orange']

3. Find the Length of a List


Program:
marks = [85, 90, 78, 92]
print(len(marks))
Output:
4

4. Access Elements of a List


Program:
subjects = ["Math", "Science", "English"]
print(subjects[0])
print(subjects[2])
Output:
Math
English

5. Sum of Elements in a List


Program:
numbers = [5, 10, 15, 20]
total = sum(numbers)
print("Sum =", total)
Output:
Sum = 50

6. Find the Largest Number in a List


Program:
numbers = [25, 78, 12, 90, 45]
print("Largest number:", max(numbers))
Output:
Largest number: 90

7. Remove an Element from a List


Program:
colors = ["Red", "Blue", "Green"]
[Link]("Blue")
print(colors)
Output:
['Red', 'Green']

8. Sort a List
Program:
numbers = [4, 1, 3, 2]
[Link]()
print(numbers)
Output:
[1, 2, 3, 4]

9. Check if an Element Exists in a List


Program:
names = ["Rahul", "Aman", "Neha"]
if "Aman" in names:
print("Aman is in the list")
Output:
Aman is in the list

10. Reverse a List


Program:
numbers = [1, 2, 3, 4]
[Link]()
print(numbers)
Output:
[4, 3, 2, 1]

You might also like