2. Lists
Q3. Create a list and perform operations: add, remove, sort, reverse.
python
Copy code
my_list = [5, 3, 8, 1]
my_list.append(10) # Add
my_list.remove(3) # Remove
my_list.sort() # Sort ascending
my_list.reverse() # Reverse
print(my_list)
Q4. Find the largest and smallest number in a list.
python
Copy code
numbers = [4, 1, 7, 3, 9]
print("Max:", max(numbers))
print("Min:", min(numbers))
4. String Operations
Q7. Perform string slicing and concatenation.
Comments
Post a Comment