Python Masterclass - Day 2 Assignment (Updated)
■ **Topics Covered:** Lists, Tuples, Sets, Dictionaries, Indexing,
Slicing, and In-built Methods
Below are your Day 2 assignments focused on Python Data Structures. Each question is designed
to enhance your understanding of real-world use cases and Pythonic data manipulation.
■ **Section 1: Lists**
1 Q1. Create a list of 10 numbers. Perform the following operations: - Find the sum and average.
- Print the maximum and minimum values. - Sort the list in ascending and descending order.
2 Q2. Write a program to add and remove elements from a list using append(), extend(), insert(),
remove(), and pop() methods.
3 Q3. Given a list ['python', 'java', 'c++', 'ruby', 'swift'], write code to slice the list to get ['java', 'c++',
'ruby'].
4 Q4. Demonstrate use of inbuilt functions: count(), index(), reverse(), copy(), clear() with
examples.
5 Q5. Write a Python program to remove duplicates from a list using set().
■ **Section 2: Tuples**
1 Q1. Create a tuple containing names of 5 cities. Display its length and type.
2 Q2. Write a Python program to convert a tuple into a list and vice versa.
3 Q3. Demonstrate tuple indexing and slicing using (10, 20, 30, 40, 50, 60).
4 Q4. Explain the difference between mutable and immutable objects with reference to tuples and
lists.
5 Q5. Use inbuilt methods like count() and index() on a tuple and explain the results.
■ **Section 3: Sets**
1 Q1. Create two sets: A = {1,2,3,4,5} and B = {4,5,6,7,8}. Perform union, intersection, difference,
and symmetric difference operations.
2 Q2. Write a Python program to add and remove elements from a set using add(), update(),
remove(), discard(), and pop() methods.
3 Q3. Demonstrate use of isdisjoint(), issubset(), and issuperset() functions with examples.
4 Q4. Convert a list with duplicate elements into a set to remove duplicates and then back to list.
5 Q5. Write a program to check whether two sets have any elements in common.
■ **Section 4: Dictionaries**
1 Q1. Create a dictionary of 5 employees with their names as keys and salaries as values. Print
all keys and values separately.
2 Q2. Demonstrate how to add, update, and delete dictionary items using appropriate methods.
3 Q3. Use inbuilt functions like keys(), values(), items(), get(), and pop() with examples.
4 Q4. Write a program to merge two dictionaries into one.
5 Q5. Write a Python script to count the occurrence of each word in a given sentence using
dictionary.
■ **Submission Note:**
Submit your completed assignment notebook with answers, outputs, and proper explanations for
each question. Make sure to include screenshots of execution for verification.