Experiment 3 Python
Experiment 3 Python
Aim:To effectively utilize Python's new data structures List and tuples for solving real-world problems
efficiently.
Problem Statement: Task List Manager: Develop a Python program to manage a task list using lists and
tuples, including adding, removing, updating, and sorting tasks.
Problem Statement: 1.Develop a Python program to manage a task list using lists and tuples, including
adding, removing, updating, and sorting tasks.
Program code:
task=['Homework' , 'Laundry', 'playing','chanting']
task.sort()
print(task)
task.insert(2,"meditation")
print(task)
task.pop()
print(task)
task.remove("Homework")
print(task)
task[2]="Exercise"
print(task)
task.append("Cycling")
print(task)
task2 =['singing','cycling']
task1=('Homework','Laundry','playing')
task2=('singing','cycling')
task1=task1+task2
print(task1)
print(task2)
li=list(task1)
li.append("Meditation")
print(li)
todo_list = ()
todo_list = tuple (task for task in todo_list if task!= "Clean the house")
print(todo_list)
print(todo_list)
todo_list = tuple(sorted(todo_list))
print(todo_list)
# Reverse the tuple (convert to list, reverse, and convert back to tuple)
todo_list = tuple(reversed(todo_list))
print(todo_list)
todo_list =()
print("\n After clearing all tasks :")
print(todo_list)
Output:
Conclusion: Thus, we studied the use of tuple and list data structure of python.