From 76e0bc0741621785a704e54dd8a641f238dcdcaf Mon Sep 17 00:00:00 2001 From: zahidulsilam Date: Thu, 24 Apr 2025 00:37:06 +0200 Subject: [PATCH 1/5] task Done --- __pycache__/base_class.cpython-312.pyc | Bin 0 -> 5188 bytes base_class.py | 99 +++++++++++++++++++++++++ data.json | 7 ++ zahid-team-leader-question1.py | 21 ++++++ 4 files changed, 127 insertions(+) create mode 100644 __pycache__/base_class.cpython-312.pyc create mode 100644 base_class.py create mode 100644 data.json create mode 100644 zahid-team-leader-question1.py diff --git a/__pycache__/base_class.cpython-312.pyc b/__pycache__/base_class.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cad6ed661cba36e9e39cf0f731f232596cb4b112 GIT binary patch literal 5188 zcmai2OKcm*8J>OdAyKBNB}MAtXjRLO=r~Gb>*1u1T{?2?!U>~PDH5xW7i-R1qC}C( z?kX}Dlp7d6(0~iuNC2s=4=R#_9Q)t`LE!=|5CJ{3C{U24Tge*%HPBOTu6#)9T>8%} zUn?o;5d3$Z|Ln~F{onkve{E`NK#+bn<(<@g2>qKBDv2*=p7cUy5n+Ux6dJdm%s9iM zlL)g{5a#Z%cF%D(%S8FFNFkoEt8B@X3r|i#W)Z1qoWW?E#mp5n&Ji8sJmx?Om? z0!TM@f%ITENH6w)Y`|WSjkp1%FWVUPSq`HB@Z5N7Xb=rYE9|CCW9evaB15F{j^VEM8Yr7j!a<^z_8Y z%V$%nqNQQP*$qnMuoUWbj-{en(ZO5Lr6LY$enSrqi#ww1wEg_knoinTsht~o^uso%M zOJc=PtS(1m89%!E{+yals4`6CQf6m?0Je0T*OGuUq5=F=zK~3*miNTPggR>^Gighh z)rfbvC@QruY=jm8Vew>uMwrK9RGlC|qRGam58hh_Kal-8(rGEedP|A9} zp$#!oXgg36pU;nMgxU)oFP1|6`PbIP@S50L6njhJ{`|;#AhZ_PUkvOo1rFqoult&> zpT2r}>HG?R??N&1$^+j~s9N*wE&BE@;|IRy*2QPP+3-g;5d-Rd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(fUAlpn!JeMZQ zw4BjcDdVa&%1p~$;waO?vyN%G_){+-$37C8n%&>Sp^8nSE{o4VU~2JXfW@aW3buqq zDx<4)oLY7;<^r{(O{Y$uYL;bZL~M3AjOT15w~jAA`rI39;r`ed zYvNX$1jssQv3ghf6ZCc(H3!G(6?B)aP+YxfF$XbInO+Bpld(J9ig4WxrABg7RfEEm zP*VC)$k;>9 zfmWTY@I$ns+~Yr+ppFDnaMNm5i$R0M%u^2kiogXLTtK{P+AyQvflPv3iB2sg(-OH5 zL0mWpV>QCPDfSFL5QpG)6bRjzUf%N{uy3Vjy*aq(z3E-*{@Aw>?pVy;%q|C)jeE+2@Zqlo z)bi|FVBg;Z`@SWy;jxF}(WiPZD81Ys>p-`nF+aB|cp$ literal 0 HcmV?d00001 diff --git a/base_class.py b/base_class.py new file mode 100644 index 0000000..e50bf8c --- /dev/null +++ b/base_class.py @@ -0,0 +1,99 @@ +import json,sys +class base_class: + + def __init__(self): + self.__status = ['completed','Pending'] + + def menu_list(self): + create_menu_list = [ + { + "text":"Add a new task Press 1", + "type":"int" + }, + { + "text":"Complete a task Press 2", + "type":"int" + }, + { + "text":"Delete a task Press 3", + "type":"int" + }, + { + "text":"List completed tasks Press 4", + "type":"int" + }, + { + "text":"List all tasks with their status Press 5" + "", + "type":"int" + }] + return create_menu_list + + def add_new_task(self): + try: + task = input("Please Enter Task") + status = input("Please Enter status") + data = self.__read_json_data() + id = self.__create_sequence_id() + data.append({"id":id,"task":task,"status":status}) + self.__write_data_in_file(data) + return "New customer added" + except Exception as e: + print(e) + + def complete_task(self): + return "Task has been completed" + + def delete_task(self): + try: + id = int(input("Please Enter the task id which you want to delete ")) + data = self.__read_json_data() + filtered_data = [item for item in data if item["id"] != id] + self.__write_data_in_file(filtered_data) + return "Successfully deleted" + except: + print("There is some Error") + def view_list_task(self): + try: + data = self.__read_json_data() + text = '' + for i in data: + text += "SR.NO: "+str(i['id'])+" Task: "+i['task']+" Status: "+i["status"]+"\n" + return text + except Exception as e: + print("There is some error to read data") + + def __find_missing_numbers(self,seq): + if not seq: + return 1 + full_range = set(range(min(seq), max(seq) + 1)) + missing = sorted(full_range - set(seq)) + if not missing: + return max(seq) + 1 + else: + return missing[0] + + def __create_sequence_id(self): + data = self.__read_json_data() + list_id = [] + for ids in data: + list_id.append(ids["id"]) + return self.__find_missing_numbers(list_id) + + def __read_json_data(self): + try: + f = open('data.json') + data = json.load(f) + f.close() + return data + except Exception as e: + print("There is some error to reada data") + + def __write_data_in_file(self,data): + try: + data = sorted(data, key=lambda x: x["id"]) + with open("data.json",'w') as file: + file.seek(0) + return json.dump(data, file, indent = 4) + except: + return "There is some error to data write in file" \ No newline at end of file diff --git a/data.json b/data.json new file mode 100644 index 0000000..9c45f18 --- /dev/null +++ b/data.json @@ -0,0 +1,7 @@ +[ + { + "id": 1, + "task": "dad", + "status": "asd" + } +] \ No newline at end of file diff --git a/zahid-team-leader-question1.py b/zahid-team-leader-question1.py new file mode 100644 index 0000000..04c7ace --- /dev/null +++ b/zahid-team-leader-question1.py @@ -0,0 +1,21 @@ +from base_class import base_class +base_function = base_class() + +try: + menu_list = base_function.menu_list() + for menu in menu_list: + print(f"{menu["text"]}\n") +except Exception as e: + print(e) +try: + menu_choice = int(input("Please Select from above menu ")) + if(menu_choice == 1): + print(base_function.add_new_task()) + elif(menu_choice == 2): + base_function.complete_task() + elif(menu_choice == 3): + base_function.delete_task() + elif(menu_choice == 4): + print(base_function.view_list_task()) +except Exception as e: + print("You selected Wrong option") \ No newline at end of file From ccb7a4dbd581d5cc169c57abfe1b801e2c74be9d Mon Sep 17 00:00:00 2001 From: zahidulsilam Date: Fri, 25 Apr 2025 15:26:53 +0200 Subject: [PATCH 2/5] status updated --- __pycache__/base_class.cpython-312.pyc | Bin 5188 -> 5616 bytes base_class.py | 12 ++++++++++-- data.json | 7 ++++++- zahid-team-leader-question1.py | 4 ++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/__pycache__/base_class.cpython-312.pyc b/__pycache__/base_class.cpython-312.pyc index cad6ed661cba36e9e39cf0f731f232596cb4b112..c8e0ae9d6b12d826e3f1afde686b1013188e9738 100644 GIT binary patch delta 942 zcmZvaT}TvB6vyZ6%*FGa}l@efZsvbI-Z|d(K%&RojE_ zR8{8K$j=5YK2u)=V*qB^glPbYE_vc0(^bzMP|5@RPcS8Rkwg)7431!>3u&U`5;C@z z&4xROOs|L)`ra$STl(2M7#;C(+$3*#CU}cK!miCq0yn|YZ@f-lsZs*CaiN7P_?g8W ztsK!Og+gFwKOxXfDM=T7hb|Ydu{SdY!N*(?rO04$bTnhz*T_A(E_j<4yzfzwVgN*F^VM%#~kF+wH;atLRZ4v|-z z=9dLrYdU_v48&8d3p{hRH+tQdx7da+*=i7MvKx19Z*_twXp2L*NmvL82!=7j@jJI2>jGBkGAYS9ftO#t9RI8etN_O_9nZS%Rq_)-lY%%z1D!Zsc}glKj0a zBNqeLLZJck@mApl zm9Olaz^hL?=is91IZI%xug-Iu?&o@6^bz&Q<~U(tRjVg*hbf;D3b|%je6>=#|5W zZSAGMYrI|;wt7~+J3dfltc9IGQYZUj>XjxeDZldOYyo|uLYOAZ5IjPIaE5T0Fz8U) yWojiRb-Bt-F!}zF>Q-y@)JejzIG1q3`gf%uNB?R3J@lb^-1Pw#_BCSqD*gb`wTxi^ diff --git a/base_class.py b/base_class.py index e50bf8c..c58ab27 100644 --- a/base_class.py +++ b/base_class.py @@ -42,7 +42,15 @@ def add_new_task(self): print(e) def complete_task(self): - return "Task has been completed" + try: + id = int(input("Please Enter the task id which you want to update ")) + rows = self.__read_json_data() + for i in rows: + i["status"] = "completed" + self.__write_data_in_file(rows) + return "Successfully updated" + except Exception as e: + print(e) def delete_task(self): try: @@ -96,4 +104,4 @@ def __write_data_in_file(self,data): file.seek(0) return json.dump(data, file, indent = 4) except: - return "There is some error to data write in file" \ No newline at end of file + return "There is some error to data write in file" diff --git a/data.json b/data.json index 9c45f18..a06dd5e 100644 --- a/data.json +++ b/data.json @@ -2,6 +2,11 @@ { "id": 1, "task": "dad", - "status": "asd" + "status": "completed" + }, + { + "id": 2, + "task": "Athis is test", + "status": "completed" } ] \ No newline at end of file diff --git a/zahid-team-leader-question1.py b/zahid-team-leader-question1.py index 04c7ace..58c0aad 100644 --- a/zahid-team-leader-question1.py +++ b/zahid-team-leader-question1.py @@ -12,9 +12,9 @@ if(menu_choice == 1): print(base_function.add_new_task()) elif(menu_choice == 2): - base_function.complete_task() + print(base_function.complete_task()) elif(menu_choice == 3): - base_function.delete_task() + print(base_function.delete_task()) elif(menu_choice == 4): print(base_function.view_list_task()) except Exception as e: From e2e752707f4460bb1a85b10e252945233c2f9198 Mon Sep 17 00:00:00 2001 From: zahidulsilam Date: Fri, 25 Apr 2025 15:31:02 +0200 Subject: [PATCH 3/5] remove , --- __pycache__/base_class.cpython-312.pyc | Bin 5616 -> 5617 bytes base_class.py | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/__pycache__/base_class.cpython-312.pyc b/__pycache__/base_class.cpython-312.pyc index c8e0ae9d6b12d826e3f1afde686b1013188e9738..418f599bfddedc9eff2532ae73e30c33cc718dc7 100644 GIT binary patch delta 144 zcmeyM{ZX6uG%qg~0}#~pac9if$oqD2vGOU*M4V zptae9Ie>{#e)CLL4<<(K&5ziv1_UG1_k~;NfIq^xRy<*T={hyqQyA2P0$D u=0k$V85vV2cL`r(Ox~O*!pX=g#;WkiU~;}_5q}0Fqx~la5Lv_nbOHdIF(**~ delta 143 zcmeyU{Xv`eG%qg~0}$l&aA&O9$oqCgG9TGlc= Date: Fri, 25 Apr 2025 20:46:08 +0200 Subject: [PATCH 4/5] Create Task Manager Application(homework) --- Task Manager Application(homework) | 80 ++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Task Manager Application(homework) diff --git a/Task Manager Application(homework) b/Task Manager Application(homework) new file mode 100644 index 0000000..f48d31f --- /dev/null +++ b/Task Manager Application(homework) @@ -0,0 +1,80 @@ +tasks = [] +next_sequence_number = 1 + +def add_task(): + global next_sequence_number + task_name = input("Enter task name: ") + + # Find the next available sequence number + sequence_number = next_sequence_number + next_sequence_number +=1 + + task = { + "sequence_number": sequence_number, + "task_name": task_name, + "status": "Pending" + } + tasks.append(task) + print(f"Task '{task_name}' added with sequence number {sequence_number}.") + +def complete_task(): + sequence_number = int(input("Enter sequence number of task to complete: ")) + for task in tasks: + if task["sequence_number"] == sequence_number: + task["status"] = "Completed" + print(f"Task '{task['task_name']}' marked as completed.") + return + print(f"Task with sequence number {sequence_number} not found.") + +def delete_task(): + sequence_number = int(input("Enter sequence number of task to delete: ")) + for task in tasks: + if task["sequence_number"] == sequence_number: + task["status"] = "Deleted" + print(f"Task '{task['task_name']}' deleted.") + return + print(f"Task with sequence number {sequence_number} not found.") + +def list_completed_tasks(): + completed_tasks = [task for task in tasks if task["status"] == "Completed"] + if completed_tasks: + print("Completed Tasks:") + for task in sorted(completed_tasks, key=lambda x: x["sequence_number"]): + print(f"- {task['sequence_number']}: {task['task_name']}") + else: + print("No completed tasks found.") + +def list_all_tasks(): + if tasks: + print("All Tasks:") + for task in sorted(tasks, key=lambda x: x["sequence_number"]): + print(f"- {task['sequence_number']}: {task['task_name']} ({task['status']})") + else: + print("No tasks found.") + +while True: + print("\nTask Manager") + print("1. Add Task") + print("2. Complete Task") + print("3. Delete Task") + print("4. List Completed Tasks") + print("5. List All Tasks") + print("6. Exit") + + choice = input("Enter your choice: ") + + if choice == '1': + add_task() + 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': + print("Exiting...") + break + else: + print("Invalid choice. Please try again.") From ad17082822d45efb1575fae972c46784bae6da42 Mon Sep 17 00:00:00 2001 From: Asem-Altaweel Date: Fri, 9 May 2025 11:57:43 +0200 Subject: [PATCH 5/5] Asem home work week 3 Asem home work week 3 --- week 3.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 week 3.py diff --git a/week 3.py b/week 3.py new file mode 100644 index 0000000..370f7aa --- /dev/null +++ b/week 3.py @@ -0,0 +1,48 @@ +list_tasks = {} +available_nums = [] +task_counter = 1 + +def get_task_num(): + global task_counter + return available_nums.pop(0) if available_nums else task_counter + +while True: + action = input("\n[A]dd [D]elete [Q]uit: ").strip().lower() + + if action == 'a': + name = input("Task name: ") + status = input("Status [C]ompleted / [P]ending: ").strip().lower() + + if status not in ['c', 'p']: + print(" Enter C or P only.") + continue + + stat = ("Completed", "Not pending") if status == 'c' else ("Not completed", "Pending") + num = get_task_num() + list_tasks[num] = {"Task Name": name, "Statuse is ": stat} + if not available_nums: task_counter += 1 + print(f" Task {num} added.") + + elif action == 'd': + try: + num = int(input("Task number to delete: ")) + if num in list_tasks: + del list_tasks[num] + available_nums.append(num) + available_nums.sort() + print(f" Task {num} deleted.") + else: + print(" Task not found.") + except: + print(" Invalid number.") + + elif action == 'q': + print(" Goodbye!") + break + + else: + print(" Invalid choice.") + + print("\n Task list:") + for n in sorted(list_tasks): + print(f"Task {n}: {list_tasks[n]}")