forked from werhereitacademy/Python_Modul_Week_3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask_Appication
More file actions
126 lines (110 loc) · 4.06 KB
/
Task_Appication
File metadata and controls
126 lines (110 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Görev durumları için sabitler (Constants), Sabitler genelde buyuk harfle tanimlanir ornek : PI = 3,14 gibi.
TAMAMLANDI = "Tamamlandı"
BEKLEMEDE = "Beklemede"
SILINDI = "Silindi"
# Görev listesi ve boş slotlar
tasks = []
empty_slots = []
# Görev ekleme fonksiyonu
def add_task(task_name):
task_id = len(tasks) + 1 if not empty_slots else empty_slots.pop(0)
tasks.append({"id": task_id, "task": task_name, "status": BEKLEMEDE})
print(f"{task_name} adlı görev eklendi. Görev ID: {task_id}")
# Görev tamamlama fonksiyonu
def complete_task():
if not tasks:
print("Hiç görev yok.")
return
print("\nTamamlanabilecek görevler:")
for task in tasks:
if task["status"] == BEKLEMEDE:
print(f"{task['id']}. {task['task']}")
try:
task_id = int(input("Tamamlamak istediğiniz görevin numarasını girin: "))
for task in tasks:
if task["id"] == task_id and task["status"] == BEKLEMEDE:
task["status"] = TAMAMLANDI
print(f"{task_id} numaralı görev tamamlandı.")
return
print("Geçersiz görev numarası.")
except ValueError:
print("Geçersiz giriş. Lütfen bir numara girin.")
# Görev silme fonksiyonu
def delete_task():
if not tasks:
print("Hiç görev yok.")
return
print("\nSilinebilecek görevler:")
for task in tasks:
if task["status"] != SILINDI:
print(f"{task['id']}. {task['task']} - Durum: {task['status']}")
try:
task_id = int(input("Silmek istediğiniz görevin numarasını girin: "))
for task in tasks:
if task["id"] == task_id and task["status"] != SILINDI:
task["status"] = SILINDI
empty_slots.append(task_id) # Silinen görevin id'sini boş slotlara ekle
print(f"{task_id} numaralı görev silindi.")
return
print("Geçersiz görev numarası.")
except ValueError:
print("Geçersiz giriş. Lütfen bir numara girin.")
# Tamamlanmış görevleri listeleme fonksiyonu
def list_completed_tasks():
print("Tamamlanmış görevler:")
completed_tasks = [task for task in tasks if task["status"] == TAMAMLANDI]
if not completed_tasks:
print("Henüz tamamlanmış görev yok.")
else:
for i, task in enumerate(completed_tasks):
print(f"{i + 1}. {task['task']}")
# Tüm görevleri listeleme fonksiyonu
def list_all_tasks():
print("Tüm görevler:")
if not tasks:
print("Hiç görev yok.")
return
for task in tasks:
print(f"{task['id']}. {task['task']} - Durum: {task['status']}")
# Görev arama fonksiyonu
def search_task():
search_term = input("Aramak istediğiniz görev adını girin: ")
found_tasks = [task for task in tasks if search_term.lower() in task["task"].lower()]
if found_tasks:
print("Bulunan görevler:")
for task in found_tasks:
print(f"{task['id']}. {task['task']} - Durum: {task['status']}")
else:
print("Hiçbir görev bulunamadı.")
# Ana Menü
def main_menu():
while True:
print("\n1. Yeni görev ekle")
print("2. Görev tamamla")
print("3. Görev sil")
print("4. Tamamlanmış görevleri listele")
print("5. Tüm görevleri listele")
print("6. Görev ara")
print("7. Çıkış")
choice = input("Bir seçenek girin: ")
if choice == '1':
task_name = input("Görev adını girin: ")
add_task(task_name)
elif choice == '2':
complete_task()
elif choice == '3':
delete_task()
elif choice == '4':
list_completed_tasks()
elif choice == '5':
list_all_tasks()
elif choice == '6':
search_task()
elif choice == '7':
print("Çıkılıyor...")
break
else:
print("Geçersiz seçim. Lütfen tekrar deneyin.")
# Programı çalıştır
if __name__ == "__main__":
main_menu()