The document outlines a lab assignment focused on list comprehension and tuples in Python. It includes tasks such as generating lists of squares, even numbers, and multiples, as well as filtering and manipulating lists and tuples. Additionally, it covers operations like sorting, reversing, and finding specific elements within tuples.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views
Lab Assignment#5
The document outlines a lab assignment focused on list comprehension and tuples in Python. It includes tasks such as generating lists of squares, even numbers, and multiples, as well as filtering and manipulating lists and tuples. Additionally, it covers operations like sorting, reversing, and finding specific elements within tuples.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
Lab Assignment#5
List Comprehension and Tuple
1. Generate a list of squares for numbers from 1 to 10 using list comprehension. 2. reate a list of even numbers between 1 and 50 using list comprehension. 3. Generate a list of the first 10 multiples of 7 using list comprehension. 4. Given a list of numbers, use list comprehension to filter out the odd numbers. 5. Given a list of words, create a list of their lengths using list comprehension. 6. Given a string, extract all vowels using list comprehension. 7. Given a list of strings, filter out words that start with a specific letter (e.g., 'A') using list comprehension. 8. Given a list of words, create a new list with each word reversed using list comprehension. 9. Generate a list of prime numbers between 1 and 100 using list comprehension. 10. Convert a 2D matrix (list of lists) into a 1D list using list comprehension. 11. Write a Python program to create a tuple, access its elements using indexing, and demonstrate slicing. 12. Write a Python program that finds the largest, smallest, and total number of elements in a numeric tuple. 13. Convert a tuple to a list, modify an element, and convert it back to a tuple. 14. Given a tuple of numbers, sort it in ascending and descending order. 15. Given a tuple with duplicate values, remove duplicates and return a new tuple. 16. Write a Python program to reverse a tuple using slicing and other methods. 17. Write a program to remove all occurrences of a specific element from a tuple. 18. Given a tuple, find the most frequently occurring element. 19. Given a tuple of numbers, return the first element that does not repeat. 20. Given a tuple of integers and a target sum, find all pairs that add up to that sum.