From 4f6c850425d2c4b9c6e1fc37972e866dd4483451 Mon Sep 17 00:00:00 2001 From: Mirac Orhan Date: Mon, 30 Dec 2024 21:43:22 +0100 Subject: [PATCH 1/6] Create Task_Manager_App.py Code Base --- Task_Manager_App.py | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Task_Manager_App.py diff --git a/Task_Manager_App.py b/Task_Manager_App.py new file mode 100644 index 0000000..a020e0e --- /dev/null +++ b/Task_Manager_App.py @@ -0,0 +1,60 @@ +tasks = [] #Task list +task_number = 1#Global Task Number for list + +#task = { +# 'Task Number': task_number, +# 'Task Name': task_name, +# 'Status': 'Pending' +#} + +# Function to add a new task +def add_task(task_name): + +# Function to mark task as completed +def complete_task(seq_num): + +# Delete task function +def delete_task(seq_num): + +# Function to list completed tasks +def list_completed_tasks(): + +# Function to list all tasks +def list_all_tasks(): + +# Main menu +def main(): + global task_number + while True: + print("\nTask Manager Menu:") + print("1. Add a new task") + print("2. Complete a task") + print("3. Delete a task") + print("4. List completed tasks") + print("5. List all tasks") + print("6. Exit") + + choice = input("Choose an option (1-6): ") + + if choice == '1': + task_name = input("Enter the task name: ") + add_task(task_name) + elif choice == '2': + seq_num = input("Enter the Task number of the task to complete: ") + complete_task(int(seq_num)) + elif choice == '3': + seq_num = input("Enter the Task number of the task to delete: ") + delete_task(int(seq_num)) + elif choice == '4': + list_completed_tasks() + elif choice == '5': + list_all_tasks() + elif choice == '6': + print("Exiting...") + break + else: + print("Invalid choice. Please select a number between 1 and 6.") + +# Start +if __name__ == "__main__": + main() From c57f8d6f6e6738516ea14f85448910ad98ba7098 Mon Sep 17 00:00:00 2001 From: Mirac Orhan Date: Thu, 2 Jan 2025 20:45:06 +0100 Subject: [PATCH 2/6] pass added --- Task_Manager_App.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Task_Manager_App.py b/Task_Manager_App.py index a020e0e..e2bd110 100644 --- a/Task_Manager_App.py +++ b/Task_Manager_App.py @@ -9,18 +9,23 @@ # Function to add a new task def add_task(task_name): + pass # Function to mark task as completed def complete_task(seq_num): + pass # Delete task function def delete_task(seq_num): + pass # Function to list completed tasks def list_completed_tasks(): + pass # Function to list all tasks def list_all_tasks(): + pass # Main menu def main(): From f7d41df2b440bf802607b176453e821618aa84b0 Mon Sep 17 00:00:00 2001 From: ifafurt Date: Thu, 2 Jan 2025 22:15:14 +0100 Subject: [PATCH 3/6] added, completed and function --- Task_Manager_App.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Task_Manager_App.py b/Task_Manager_App.py index e2bd110..7a53176 100644 --- a/Task_Manager_App.py +++ b/Task_Manager_App.py @@ -9,15 +9,34 @@ # Function to add a new task def add_task(task_name): - pass + global task_number + task = { + 'Task Number': task_number, + 'Task Name': task_name, + 'Status': 'Pending' + } + tasks.append(task) + task_number += 1 + print(f"Task '{task_name}' has been added.") # Function to mark task as completed def complete_task(seq_num): - pass + for task in tasks: + if task['Task Number'] == seq_num: + task['Status'] = 'Completed' + print(f"Task {seq_num} marked as completed.") + break + print(f"Task {seq_num} not found.") # Delete task function def delete_task(seq_num): - pass + global tasks + task_to_delete = None + for task in tasks: + if task['Task Number'] == seq_num: + task_to_delete = task + break + print(f"Task {seq_num} has been deleted.") # Function to list completed tasks def list_completed_tasks(): From 6c6901019fbc0ee552e60ec2b47969caacc7ae72 Mon Sep 17 00:00:00 2001 From: Emnyldrmdgn Date: Thu, 2 Jan 2025 23:40:40 +0100 Subject: [PATCH 4/6] Update Task_Manager_App.py added list_completed_tasks and list_all_tasks --- Task_Manager_App.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Task_Manager_App.py b/Task_Manager_App.py index 7a53176..0fd91dd 100644 --- a/Task_Manager_App.py +++ b/Task_Manager_App.py @@ -40,11 +40,25 @@ def delete_task(seq_num): # Function to list completed tasks def list_completed_tasks(): - pass + completed_tasks = [task for task in tasks if task['Status'] == 'Completed'] + + if not completed_tasks: + print("No completed tasks available.") + return + + print("\nCompleted Tasks:") + for task in completed_tasks: + print(f"Task Number: {task['Task Number']}, Task Name: {task['Task Name']}") # Function to list all tasks def list_all_tasks(): - pass + if not tasks: + print("No tasks available.") + return + + print("\nAll Tasks:") + for task in tasks: + print(f"Task Number: {task['Task Number']}, Task Name: {task['Task Name']}, Status: {task['Status']}") # Main menu def main(): From 1a5415a6a59560f1b4b59313a47fba328f2eb2b1 Mon Sep 17 00:00:00 2001 From: Mirac Orhan Date: Fri, 3 Jan 2025 16:09:06 +0100 Subject: [PATCH 5/6] added hackerrank answers --- hackerrank.py | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 hackerrank.py diff --git a/hackerrank.py b/hackerrank.py new file mode 100644 index 0000000..67547f9 --- /dev/null +++ b/hackerrank.py @@ -0,0 +1,97 @@ +### Hacker Rank +#Question 1 +#https://www.hackerrank.com/challenges/find-digits/problem +# Bir tamsayı d, tamsayı n'in böleni ise, n % d = 0 olduğunda bu durumu sağlar. +# Bir tamsayı verildiğinde, bu sayıyı oluşturan her bir rakamı kontrol edin ve bu rakamın n'in böleni olup olmadığını belirleyin. Sayı içinde geçen bölenlerin sayısını bulun. +# Örnek: +# makefile +# Kodu kopyala +# n = 124 +# 1, 2 ve 4 rakamlarının her birinin 124 sayısının böleni olup olmadığını kontrol edin. 1, 2 ve 4, 124'ü bölebilir, bu nedenle sonuç 3 olacaktır. +# n = 111 +# 1, 1 ve 1 rakamlarının her birinin 111 sayısının böleni olup olmadığını kontrol edin. 1, 1 ve 1, 111'i bölebilir, bu nedenle sonuç 3 olacaktır. +# n = 10 +# 1 ve 0 rakamlarının her birinin 10 sayısının böleni olup olmadığını kontrol edin. 1, 10'u böler, ancak 0 bölemez. Bu yüzden sonuç 1 olacaktır. +# Fonksiyon Açıklaması +# Aşağıdaki fonksiyonu tamamlayın: +# python +# Kodu kopyala +# findDigits(n: int) -> int +# Parametreler: +# n: Kontrol edilecek tam sayı. +# Döndürülecek Sonuç: +# int: n sayısındaki rakamların, n'in böleni olduğu rakam sayısı. +# Girdi Formatı: +# İlk satırda bir tam sayı t bulunur, bu da test durumu sayısını belirtir. +# Sonraki t satırın her birinde bir tam sayı n bulunur. +# Kısıtlamalar: +# 1 ≤ t ≤ 15 +# 0 ≤ n < 10^9 +# Örnek Girdi: +# 2 +# 12 +# 1012 +# Örnek Çıktı: +# 2 +# 3 +# Açıklama: +# 12 sayısı iki rakama ayrılır: 1 ve 2. 12 sayısı hem 1'e hem de 2'ye bölünebilir, bu yüzden sonuç 2'dir. +# 1012 sayısı dört rakama ayrılır: 1, 0, 1 ve 2. 1012 sayısı 1, 1 ve 2 ile tam bölünebilir, ancak 0 ile bölünemez, çünkü sıfıra bölme tanımsızdır. Bu yüzden sonuç 3'tür. +#Answer 1 +import math # Imports the 'math' module, though not used here +import os # Imports the 'os' module to interact with the operating system +import random # Imports the 'random' module, though not used here +import re # Imports the 're' (regular expressions) module, though not used here +import sys # Imports the 'sys' module, though not used here + +# Complete the 'findDigits' function below. +# The function is expected to return an INTEGER. +# The function accepts INTEGER n as parameter. + +def findDigits(n): # Defines the 'findDigits' function which takes 'n' (an integer) as a parameter. + count = 0 # Initializes a variable 'count' to keep track of the valid digits divisible by 'n'. + for digit in str(n): # Converts the integer 'n' to a string and iterates over each digit as a character. + d = int(digit) # Converts the current character back to an integer. + if d != 0 and n % d == 0: # Checks if the digit is not zero and divides 'n' without a remainder. + count += 1 # If both conditions are true, increments the count. + return count # Returns the count of digits that divide 'n'. + +if __name__ == '__main__': # Main function execution starts here. + fptr = open(os.environ['OUTPUT_PATH'], 'w') # Opens a file for writing the output (system/environment specified path). + + t = int(input().strip()) # Reads the number of test cases 't' from user input and converts it to an integer. + + for t_itr in range(t): # Iterates through each test case 't_itr'. + n = int(input().strip()) # For each test case, reads an integer 'n' from input. + + result = findDigits(n) # Calls the 'findDigits' function and stores the result. + + fptr.write(str(result) + '\n') # Writes the result of the function into the output file. + + fptr.close() # Closes the file after writing all outputs. + + +#Question 2 +#https://www.hackerrank.com/challenges/capitalize/problem +#Answer 2 +import math # Imports the 'math' module, though not used here. +import os # Imports the 'os' module for file interaction. +import random # Imports the 'random' module, though not used here. +import re # Imports the 're' module, though not used here. +import sys # Imports the 'sys' module, though not used here. + +# Complete the solve function below. +def solve(name): # Defines the 'solve' function, which accepts a string 'name' as input. + return ' '.join(word.capitalize() for word in name.split()) # Splits the string by spaces, capitalizes the first letter of each word, and joins them back into a string. + +if __name__ == '__main__': # Main function execution starts here. + fptr = open(os.environ['OUTPUT_PATH'], 'w') # Opens a file for writing the output. + + s = input() # Reads the input string 's'. + + result = solve(s) # Calls the 'solve' function on 's' and stores the result. + + fptr.write(result + '\n') # Writes the result into the output file. + + fptr.close() # Closes the file after writing all outputs. + From 3829ee5a6adf359494bfa2e612efaa8f7cc029a7 Mon Sep 17 00:00:00 2001 From: Mirac Orhan Date: Fri, 3 Jan 2025 19:17:51 +0100 Subject: [PATCH 6/6] fix code --- Task_Manager_App.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Task_Manager_App.py b/Task_Manager_App.py index 0fd91dd..09a0cc1 100644 --- a/Task_Manager_App.py +++ b/Task_Manager_App.py @@ -31,10 +31,9 @@ def complete_task(seq_num): # Delete task function def delete_task(seq_num): global tasks - task_to_delete = None for task in tasks: if task['Task Number'] == seq_num: - task_to_delete = task + task['Status'] = 'Deleted' break print(f"Task {seq_num} has been deleted.")