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.
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.
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.
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.
Official reference for python list data structure