0% found this document useful (0 votes)
5 views

Lab Assignment#4

This lab assignment consists of 15 tasks focused on list manipulation in programming. Tasks include creating and accessing lists, slicing, updating, merging, sorting, and performing operations like matrix addition and finding prime numbers. Students are required to implement various algorithms and functions to demonstrate their understanding of list operations.

Uploaded by

singhsanjay2974
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lab Assignment#4

This lab assignment consists of 15 tasks focused on list manipulation in programming. Tasks include creating and accessing lists, slicing, updating, merging, sorting, and performing operations like matrix addition and finding prime numbers. Students are required to implement various algorithms and functions to demonstrate their understanding of list operations.

Uploaded by

singhsanjay2974
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab Assignment#4

1. Create and Access Elements in a List


Write a program to create a list of 10 integers, then access and print the first, last, and
a user-specified element.
2. Slicing and Indexing
Create a list of 20 random integers. Demonstrate list slicing by extracting subsets of
the list such as the first 5 elements, last 5 elements, and every alternate element.
3. Updating and Deleting Elements
Write a program to update the second element of a list and delete the fifth element.
Print the list before and after these operations.

4. Merging Two Lists


Take two lists of integers from the user and merge them into a single list. Remove any
duplicate elements.
5. Sorting a List
Create a list of unsorted floating-point numbers. Write a program to sort the list in
ascending and descending order without using the sorted() function.
6. List Reversal
Write a program to reverse a list without using built-in functions like reverse().
7. Finding Maximum and Minimum
Write a program to find the maximum and minimum numbers in a list without using
built-in functions like max() or min().
8. Frequency Count
Take a list of integers and count the frequency of each unique element. Display the
results in the form of a table.

9. Matrix Representation
Represent a 3x3 matrix as a list of lists. Perform matrix addition and subtraction.
10. Prime Numbers in a Range
Write a program to generate a list of prime numbers between two user-specified
integers.
11. Even and Odd Segregation
Create a list of integers and separate it into two lists: one containing all even numbers
and the other containing all odd numbers.
12. Cumulative Sum
Write a program to create a list of cumulative sums from a given list. For example,
[1, 2, 3, 4] should output [1, 3, 6, 10].
13. List of Squares
Generate a list of squares of numbers from 1 to n, where n is user-defined.

14. Palindromic List


Check if a given list is a palindrome (reads the same forward and backward).
15. Flatten a Nested List
Write a program to flatten a nested list (e.g., [[1, 2], [3, 4], [5]] should
become [1, 2, 3, 4, 5]).

You might also like