Skip to content

Commit 11e95f3

Browse files
committed
Projeto ToDo List
1 parent f5891f9 commit 11e95f3

2 files changed

Lines changed: 162 additions & 0 deletions

File tree

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
task_list = []
2+
3+
4+
5+
# Função criar tarefas
6+
def new_tasks(name=str, description=str, category=str,priority=str, status=str):
7+
8+
name = input("Tarefa:\n")
9+
description = input("Descrição:\n ")
10+
category = input("Categoria:\n")
11+
status = "Em andamento."
12+
while True:
13+
14+
opcao = input("""
15+
=-=-=-=-=-=PRIORIDADE=-=-=-=-=-=
16+
17+
1 - BAIXA
18+
2 - MÉDIA
19+
3 - ALTA
20+
21+
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
22+
\nESCOLHA UMA OPÇÃO: """)
23+
24+
25+
if opcao not in ["1", "2", "3"]:
26+
print("Escolha uma opção válida!")
27+
28+
else:
29+
match opcao:
30+
case "1":
31+
priority = "BAIXA"
32+
break
33+
case "2":
34+
priority = "MÉDIA"
35+
break
36+
case "3":
37+
priority = "ALTA"
38+
break
39+
new_task = {
40+
"Tarefa": name,
41+
"Descrição": description,
42+
"Categoria": category,
43+
"Prioridade": priority,
44+
"Status":status
45+
}
46+
task_list.append(new_task)
47+
48+
49+
# ================================================================================================
50+
# Função que exibi todas as tarefas
51+
def display_tasks():
52+
if not task_list:
53+
print("Lista está vazia!")
54+
else:
55+
for i, element in enumerate(task_list):
56+
print(f"""
57+
{i+1} - {element['Tarefa']}
58+
Descrição: {element['Descrição']}
59+
Categoria: {element['Categoria']}
60+
Prioridade: {element['Prioridade']}
61+
Status: {element['Status']}
62+
""")
63+
64+
# ================================================================================================
65+
# Função para concluir tarefa
66+
def task_status():
67+
indice = int(input("Digite o número da tarefa: ")) - 1
68+
69+
if 0 <= indice < len(task_list):
70+
tarefa = task_list[indice]
71+
tarefa["Status"] = "Concluído."
72+
print(f"Tarefa '{tarefa['Tarefa']}' foi concluída com sucesso!")
73+
else:
74+
print("Tarefa não encontrada.")
75+
76+
77+
# ================================================================================================
78+
# Função para filtrar categoria
79+
def filter_category():
80+
category = input("Digite a categoria que deseja buscar: ")
81+
result = []
82+
83+
for task in task_list:
84+
if task["Categoria"].lower() == category.lower():
85+
result.append(task)
86+
87+
if not result:
88+
print("Nenhuma tarefa encontrada nessa categoria.")
89+
else:
90+
print("\nTarefas encontradas:\n")
91+
92+
for task in result:
93+
print(f"Tarefa: {task['Tarefa']}")
94+
print(f"Descrição: {task['Descrição']}")
95+
print(f"Categoria: {task['Categoria']}")
96+
print(f"Prioridade: {task['Prioridade']}")
97+
print(f"Status: {task['Status']}")
98+
print("-" * 30)
99+
100+
# ================================================================================================
101+
# Função para filtrar Prioridade
102+
def filter_priority():
103+
priority = input("Digite a prioridade (BAIXA, MÉDIA, ALTA): ")
104+
result = []
105+
106+
for task in task_list:
107+
if task["Prioridade"].lower() == priority.lower():
108+
result.append(task)
109+
110+
if not result:
111+
print("Nenhuma tarefa encontrada com essa Prioridade.")
112+
else:
113+
print("\nTarefas encontradas:\n")
114+
for task in result:
115+
print(f"Tarefa: {task['Tarefa']}")
116+
print(f"Descrição: {task['Descrição']}")
117+
print(f"Categoria: {task['Categoria']}")
118+
print(f"Prioridade: {task['Prioridade']}")
119+
print(f"Status: {task['Status']}")
120+
print("-" * 30)
121+
122+
# ================================================================================================
123+
# Funçào para exibir Menu
124+
def display_menu():
125+
print("\n1 - Adicinar tarefa")
126+
print("2 - Listar tarefas")
127+
print("3 - Filtrar Categoria")
128+
print("4 - Filtrar Prioridade")
129+
print("5 - Marca concluído")
130+
131+
132+
# ================================================================================================
133+
# Função de encerrar o sistema
134+
def main():
135+
while True:
136+
display_menu()
137+
opcao = input("\nEscolha uma opção: ")
138+
139+
140+
match opcao:
141+
case "1":
142+
# Adicinar nova tarefa
143+
new_tasks()
144+
case "2":
145+
# Verificar tarefas
146+
display_tasks()
147+
148+
case "3":
149+
filter_category()
150+
151+
case "4":
152+
filter_priority()
153+
154+
case "5":
155+
task_status()
156+
157+
case "0":
158+
print("Você escolheu a opção de sair.")
159+
print("Saindo...")
160+
break
161+
162+
main()

Mod02/atividades-Funcoes/ToDo_list.py

Whitespace-only changes.

0 commit comments

Comments
 (0)