0% found this document useful (0 votes)
8 views2 pages

Project 1

The document outlines a simple to-do list application using functions and data structures in Python. It includes functions to add tasks, display tasks, and mark tasks as completed, along with a main loop for user interaction. The application allows users to manage their tasks through a menu-driven interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Project 1

The document outlines a simple to-do list application using functions and data structures in Python. It includes functions to add tasks, display tasks, and mark tasks as completed, along with a main loop for user interaction. The application allows users to manage their tasks through a menu-driven interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

DEVELOP A TO-DO-LIST APPLICATION S USING FUNCTION AND DATA STRUCTURES:

# Define an empty list to store tasks

Tasks = []

# Function to add a task to the list

Def add_task(task):

Tasks.append(task)

Print(f’Task “{task}” added successfully.’)

# Function to display the tasks in the list

Def display_tasks():

If not tasks:

Print(‘No tasks in the list.’)

Else:

Print(‘Tasks:’)

For index, task in enumerate(tasks, start=1):

Print(f’{index}. {task}’)

# Function to mark a task as completed

Def complete_task(index):

If 1 <= index <= len(tasks):

Completed_task = tasks.pop(index – 1)

Print(f’Task “{completed_task}” marked as completed.’)

Else:

Print(‘Invalid task index.’)

# Main loop for user interaction

While True:

Print(‘\nOptions:’)

Print(‘1. Add Task’)

Print(‘2. Display Tasks’)

Print(‘3. Complete Task’)

Print(‘4. Quit’)
Choice = input(‘Enter your choice (1-4): ‘)

If choice == ‘1’:

Task_name = input(‘Enter task name: ‘)

Add_task(task_name)

Elif choice == ‘2’:

Display_tasks()

Elif choice == ‘3’:

Task_index = int(input(‘Enter the index of the task to mark as completed: ‘))

Complete_task(task_index)

Elif choice == ‘4’:

Print(‘Exiting the to-do list application. Goodbye!’)

Break

Else:

Print(‘Invalid choice. Please enter a number between 1 and 4.’)

You might also like