Python Program to Remove All Tuples in a List Outside the Given Range

This is a Python Program to remove all tuples in a list of tuples with the USN outside the given range. Problem Description The program removes all tuples in a list of tuples with the USN outside the given range. Problem Solution 1. Take in the lower and upper roll number from the user. 2. … Read more

advertisement

Python Program to Remove Duplicates from a List

This is a Python Program to remove the duplicate items from a list. Problem Description The program takes a lists and removes the duplicate items from the list. Problem Solution 1. Take the number of elements in the list and store it in a variable. 2. Accept the values into the list using a for … Read more

advertisement

Python Program to Merge Two Lists and Sort it

This is a Python Program to merge two lists and sort it. Problem Description The program takes two lists, merges them and sorts the merged list. Problem Solution 1. Take in the number of elements for the first list and store it in a variable. 2. Take in the elements of the list one by … Read more

advertisement

Python Program to Find the Union of Two Lists

This is a Python Program to find the union of two lists. Problem Description The program takes two lists and finds the unions of the two lists. Problem Solution 1. Define a function which accepts two lists and returns the union of them. 2. Declare two empty lists and initialise to an empty list. 3. … Read more

advertisement

Python Program to Create a List of Tuples with the First Element as the Number and Second Element as the Square of the Number

This is a Python Program to create a list of tuples with the first element as the number and the second element as the square of the number. Problem Description The program takes a range and creates a list of tuples within that range with the first element as the number and the second element … Read more

advertisement

Python Program to Find the Cumulative Sum of a List

This is a Python Program to find the cumulative sum of a list where the ith element is the sum of the first i+1 elements from the original list. Problem Description The program takes a list from the user and finds the cumulative sum of a list where the ith element is the sum of … Read more

advertisement

Python Program to Find Second Largest Number in a List

This is a Python Program to find the second largest number in a list. Problem Description The program takes a list and prints the second largest number in the list. Problem Solution 1. Take in the number of elements and store it in a variable. 2. Take in the elements of the list one by … Read more

advertisement

Python Program to Split Even and Odd Elements into Two Lists

This is a Python Program to put the even and odd elements in a list into two different lists. Problem Description The program takes a list and puts the even and odd elements in it into two separate lists. Problem Solution 1. Take in the number of elements and store it in a variable. 2. … Read more

advertisement

Python Program to Sort a List According to the Second Element in Sublist

This is a Python Program to sort the list according to the second element in the sublist. Problem Description The program takes a list of lists and sorts the list according to the second element in the sublist. Problem Solution 1. Take in a list containing sublists. 2. Using two for loops, use bubble sort … Read more

advertisement

Python Program to Generate Random Numbers from 1 to 20 and Append Them to the List

This is a Python Program to generate random numbers from 1 to 20 and append them to the list. Problem Description The program takes in the number of elements and generates random numbers from 1 to 20 and appends them to the list. Problem Solution 1. Import the random module into the program. 2. Take … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.