Important 30 python list manipulation programs
In this article, you will get the important python list manipulation programs. Students, these programs can be a part of your practical file. So let us start!
Important python list manipulation programs
Here we have some python list manipulation programs or python list programming questions or Important python programs on lists. We will see all of these class 11 python program questions in different sections like create lists, traverse lists, list operations, and list functions and methods. So here we go!
In the first section of Important python list manipulation programs, we will see the programs based on list creation and traversal. This list will help students who are looking for python programs for beginners or python practical programs.
[1] Create a list of the following numbers and print them with their index.
l = [22,45,67,89,6,1,34,56,89,10]
print(“Index – [0]: “,l[0])
print(“Index – [1]: “,l[1])
print(“Index – [2]: “,l[2])
print(“Index – [3]: “,l[3])
print(“Index – [4]: “,l[4])
[2] Create a list of your friends’ names and print them.
list_frnds= [“Anurag”,”Bhargav”,”Chandrkant”,”Harshad”,”Jayesh”,”Mithun”]
for i in range(0,len(list_frnds)):
print(“Freind[“,i,”]:”,list_frnds[i])
[3] Create a list of heights of 5 students and print the list. (Use mixed numbers integer and decimal both)
[4] Create a list of the first letter of your friend’s names and print the list.
list_frnds= [“Anurag”,”Bhargav”,”Chandrkant”,”Harshad”,”Jayesh”,”Mithun”]
l=[]
for i in range(0,len(list_frnds)):
l.append(list_frnds[i][0])
print(l)
[5] Write some lines about “Bharat is best” and make a list of words used in the input.
[6] Create a list named friends and include elements like name, date of birth, lucky number, favorite colour, weight, and height.
name = input(“Enter Name:”)
lucky_no = int(input(“Enter Lucky Number:”))
fav_col = input(“Enter favorite color:”)
w = int(input(“Enter weight:”))
h =int(input(“Enter height:”))
friends=[]
friends.append([name,lucky_no,fav_col,w,h])
print(l)
For the next programs of list programs in python for practice python or programs for class 11 ip or this article programs on the list for class 11, ask the user to input the list elements and then do as directed.
[7] Calculate the total number of zeros, positive and negative elements in the list.
l=[23,4,56,-1,0,46,-8,-9,0,-11,31,21]
z=0
p=0
n=0
for i in range(len(l)):
if l[i]==0:
z+=1
elif l[i]>0:
p+=1
else:
n+=1
print(“Total No. of zeros in the list are:”,z)
print(“Total No. of positive numbers in the list are:”,p)
print(“Total No. of negative numbers in the list are:”,p)
[8] Find out the maximum and minimum element from the array. (Don’t use any function)
[9] Find out the difference between maximum and minimum elements of the list.
[10] Arrange the elements of a list in increasing order of their value.
[11] Arrange the elements of a list in decreasing order of their value.
[12] Read a number from the keyboard and check whether the entered number is present or not in the list. If present, then also print the occurrences of a entered number.
[13] Find out the average of n elements.
[14] Find out the sum of each elements in the list.
[15] Find out the total number of even elements in the list.
[16] Find out the total number of odd elements in the list.
[17] Suppress all zero elements at the bottom of the list.
[18] Suppress all negative elements at the bottom of the list.
[19] Suppress all positive elements at the bottom of the list.
[20] Suppress all non-zero elements at the bottom of the list.
[21] Return the largest even number from the list, if there no even number in the input, print “Even not found in the list”.
[22] Find the sum of even indexed elements from the list.
[23] Find the product of odd indexed elements from the list.
[24] Write a program to take in the roll number, name and percentage of marks for n students of Class XI and do the following:
- Accept details of the n students (n is the number of students).
- Search details of a particular student on the basis of roll number and display result.
- Display the result of all the students.
- Find the topper amongst them.
- Find the subject toppers amongst them.
You can use nested list.
[25] Create a list with some duplicate values and Remove all the duplicates from the list.
[26] Create a list and check whether your list is having any element or empty.
[27] Create a list and count the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.
[28] Create carbon copy of the list.
[29] Write a Python program to print a specified list after removing the 0th, 3rd and 5th elements.
Example: [2,3,4,5,6,7,8] then output will be [3,4,6,8]
[30] Print your list after removing all elements which are divided by 3.
Some programs on list for class 11 which is given in the NCERT Solutions. Follow the below given list to access them.
Follow the below given links to understand the concept and that can help your to do the programs on list for class 11.
Python List Programs, Exercises
Python list programs help beginners to become experts and the list is one of the most important data structures in Python Programming. Python list can contain any type of data as a member that we can access via positive and negative indexing.
In this article, we have two different sections one for Python list programs for beginners and the second for Python list projects for practice.
Python List Programs
1). Python program to calculate the square of each number from the given list.
2). Python program to combine two lists.
3). Python program to calculate the sum of all elements from a list.
4). Python program to find a product of all elements from a given list.
5). Python program to find the minimum and maximum elements from the list.
6). Python program to differentiate even and odd elements from the given list.
7) . Python program to remove all duplicate elements from the list.
8) . Python program to print a combination of 2 elements from the list whose sum is 10.
9) . Python program to print squares of all even numbers in a list.
10). Python program to split the list into two-part, the left side all odd values and the right side all even values.
Input = [5, 7, 2, 8, 11, 12, 17, 19, 22]Output = [5, 7, 11, 17, 19, 2, 8, 12, 22]
11). Python program to get common elements from two lists.
Input =
list1 = [4, 5, 7, 9, 2, 1]list2 = [2, 5, 8, 3, 4, 7]Outputt : [4, 5, 7, 2]
12). Python program to reverse a list with for loop.
13). Python program to reverse a list with a while loop.
14). Python program to reverse a list using index slicing.
15). Python program to reverse a list with reversed and reverse methods.
16). Python program to copy or clone one list to another list.
17). Python program to return True if two lists have any common member.
18). Python program to print a specific list after removing the 1st, 3rd, and 6th elements from the list.
19). Python program to remove negative values from the list.
20). Python program to get a list of all elements which are divided by 3 and 7.
21). Python program to check whether the given list is palindrome or not. (should be equal from both sides).
23). Python program to add 2 lists with extend method.
24). Python program to sort list data, with the sort and sorted method.
25). Python program to remove data from the list from a specific index using the pop method.
26). Python program to get the max, min, and sum of the list using in-built functions.
27). Python program to check whether a list contains a sublist.
28). Python program to generate all sublists with 5 or more elements in it from the given list.
30). Python program to find the second smallest number from the list.
31). Python program to merge all elements of the list in a single entity using a special character.
32). Python program to get the difference between two lists.
36). Python program to get all the unique numbers in the list.
37). Python program to convert a string into a list.
39). Python program to check whether the given element is exist in the list or not.
41). Python program to take two lists and return true if then at least one common member.
48). Python program to iterate over two lists simultaneously and create a list of sublists.
49). Python program to move all positive numbers on the left side and negative numbers on the right side.
51). Python program to find the list in a list of lists whose sum of elements is the highest.
52). Python program to find the items that start with a specific character from a given list.
55). Python program to pack consecutive duplicates of given list elements into sublists.
56). Python program to split a given list into two parts where the length of the first part of the list is given.
61). Python program to convert the first and last letter of each item from Upper case and lowercase.
63). Python program to sort a given list in ascending order according to the sum of its sublist.
64). Python program to extract the specified sizes of strings from a given list of string values.
68). Python program to access multiple elements of the specified index from a given list.
77). Python program to get the factorial of each item in the list.
78). Python program to get a list of Fibonacci numbers from 1 to 20.
88). Python program to calculate percentage from a given mark list, the max mark for each item is 100.
94). Python program to convert the 3rd character of each word to a capital case from the given list.
96). Python program to get a length of each word and add it as a dictionary from the given list.
99). Python program to round every number in a given list of numbers and print the total sum of the list.
list1 = [2, 4, 6, 7, 5, 8, 3, 11] result = [x**2 for x in list1 if x%2 == 0] print("Result :", result) Output : Result : [4, 16, 36, 64]
list1 = [2, 4, 6, 7, 5, 8, 3, 11] result = [x**2 for x in list1 if x%2 == 0] print("Result :", result) Output : Result : [4, 16, 36, 64]
101). Python Program to get the Standard deviation of the list element.
102). Python program to convert all numbers to binary format from a given list.
103). Python program to convert all the numbers into Roman numbers from the given list.
Python Lists Project Ideas
1). To-do List: Python list program that allows users to create and manage their to-do lists. Users can add, delete, and update tasks on their list. Each task can add along with a unique id which will first element of each sub-list through which the user can easily identify the item and task.
2). Shopping List: A program that allows users to create and manage their shopping list. Users can add, delete, and update items on their list. There are many Python list programs listed above those can help user to solve this project.
3). Game Leaderboard: A program that keeps track of scores for multiple players in a game. Use Python lists to store the scores and display a leaderboard of the top players. Nowadays people like to play games and users can apply a basic understanding of Python list programs to write code for this mini-project.
4). Student Gradebook: A Python list program that allows teachers to enter and manage student grades. Use Python lists and sub-lists to store student names and their corresponding grades.
5). Password Manager: A program that securely stores and manages passwords using Python lists. Users can add, delete, and update passwords, and the program can encrypt the data for added security, Its good exercises to apply understanding Python list programs.
6). Music Library: A Python list program that allows users to create and manage a music library. Users can add, delete, and update songs, artists, and album details in the list.
7). Recipe Book: A program that allows users to create and manage their recipe book. Users can add, delete, and update recipes, ingredients, and cooking instructions.
8). Contact List: A Python list program that allows users to manage their contact list. Users can add, delete, and update contacts’ names, phone numbers, and email addresses in the list.
9). Movie Library: A Python list program that allows users to create and manage a movie library. Users can add, delete, and update movies, actors, and directors in the list.
10). Sports Team Roster: A program that allows coaches to manage their sports team roster. Coaches can add, delete, and update players’ names, positions, and statistics in the list.