File: exp2a.ipynb
Experiment Title: Study of Python Lists
Author: Ronit Mehta
PRN: 25070123094
To study and understand Python Lists and perform basic list operations such as creation, indexing, insertion, updating, extension, slicing, sorting, and aggregation (maximum, minimum, and average).
A list in Python is an ordered and mutable collection of elements enclosed within square brackets [].
- Can store multiple data types (int, float, string, boolean, etc.)
- Supports indexing and negative indexing
- Elements can be modified after creation
- Provides several built-in methods such as:
append()insert()extend()remove()sort()
- Supports built-in functions like:
len()sum()max()min()
Lists are widely used for storing and manipulating grouped data efficiently in Python programs.
- Display student name and PRN using markdown.
- Display the aim of the experiment.
- Create a list of fruits.
- Display the list.
Output ['apple', 'orange', 'cherry']
- Create a list with mixed data types.
- Display the list.
- Find and print the length of the list.
Output [2, 2.5, True, 'ronit'] 4
- Create a list of fruits.
- Access elements using positive and negative indexing.
- Add a new element using
append(). - Display the updated list.
Output apple orange apple cherry ['apple', 'orange', 'cherry', 'banana']
- Insert an element at a specific index using
insert(). - Display the list.
Output ['apple', 'banana', 'orange', 'cherry']
- Modify an element using index assignment.
- Display the updated list.
Output ['apple', 'banana', 'cherry']
- Create two lists.
- Concatenate lists using
+. - Extend one list using
extend(). - Display the final list.
Output ['apple', 'orange', 'cherry', 'mango', 'pineapple', 'banana']
- Create a list with multiple elements.
- Perform slicing operations.
- Display sliced lists.
Output ['cherry', 'kiwi', 'mango'] ['cherry', 'kiwi', 'mango', 'pineapple', 'banana'] ['apple', 'orange', 'cherry', 'kiwi']
- Create a list of student names.
- Remove a specific name.
- Sort the list alphabetically.
- Display results.
Output ['ronit', 'apoorba', 'rishabh', 'rupsa', 'soham'] ['ronit', 'apoorba', 'rishabh', 'soham'] ['apoorba', 'rishabh', 'ronit', 'soham']
- Create a list of marks.
- Find maximum and minimum values.
- Calculate average.
- Sort the list.
Output 98 44 59.166666666666664 [44, 45, 46, 55, 67, 98]
This experiment successfully demonstrates the fundamental operations of Python Lists, including creation, indexing, insertion, updating, slicing, sorting, and aggregation.
The experiment helped in understanding:
- How lists store and manage data
- How built-in methods simplify data manipulation
- Why lists are one of the most important data structures in Python
Python lists provide flexibility and efficiency, making them essential for real-world programming tasks.