From 6c50e19de0c77a6d28e100d89253252c4d3cbb1c Mon Sep 17 00:00:00 2001 From: Enginneer887766 <70516735+Enginneer887766@users.noreply.github.com> Date: Sat, 20 Sep 2025 09:34:13 +0530 Subject: [PATCH 1/6] Update calculator --- calculator/main.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/calculator/main.py b/calculator/main.py index 43bf23b..13265fd 100644 --- a/calculator/main.py +++ b/calculator/main.py @@ -3,19 +3,26 @@ def add(a, b): # TODO: Return sum of a and b + return(a+b) pass def subtract(a, b): # TODO: Return difference of a and b + return(a-b) pass def multiply(a, b): # TODO: Return product of a and b + return(a*b) pass def divide(a, b): # TODO: Return quotient of a and b # Handle division by zero + + if b==0: + return "Error" + return (a/b) pass def main(): @@ -26,7 +33,17 @@ def main(): num1 = float(input("Enter first number: ")) operator = input("Enter operator: ") num2 = float(input("Enter second number: ")) - + if operator == "+": + result = add(num1, num2) + elif operator == "-": + result = subtract(num1, num2) + elif operator == "*": + result = multiply(num1, num2) + elif operator == "/": + result = divide(num1, num2) + else: + result = "Invalid operator" + print("Result",result) # Match the operator with the correct function except ValueError: From 0d098ec8cc3bb73045e8549a329b926d83f7c39e Mon Sep 17 00:00:00 2001 From: Enginneer887766 <70516735+Enginneer887766@users.noreply.github.com> Date: Sat, 20 Sep 2025 09:44:32 +0530 Subject: [PATCH 2/6] Completed convert-distance --- convert-distance/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/convert-distance/main.py b/convert-distance/main.py index f6bcfe8..b663b14 100644 --- a/convert-distance/main.py +++ b/convert-distance/main.py @@ -3,14 +3,17 @@ def km_to_m(km): # TODO: Convert kilometers to meters + return (km*1000) pass def m_to_cm(m): # TODO: Convert meters to centimeters + return (m*100) pass def cm_to_km(cm): # TODO: Convert centimeters to kilometers + return (cm/100000) pass def main(): @@ -24,15 +27,18 @@ def main(): if choice == "1": km = float(input("Enter distance in kilometers: ")) + result = km_to_m(km) # Call conversion function elif choice == "2": m = float(input("Enter distance in meters: ")) + result = m_to_cm(m) # Call conversion function elif choice == "3": cm = float(input("Enter distance in centimeters: ")) + result = cm_to_km(cm) # Call conversion function else: print("Invalid choice!") - + print("Result:",result) if __name__ == "__main__": main() From 03462df0e9340dbbc468ffd9f91c47503549c509 Mon Sep 17 00:00:00 2001 From: Enginneer887766 <70516735+Enginneer887766@users.noreply.github.com> Date: Sat, 20 Sep 2025 09:57:42 +0530 Subject: [PATCH 3/6] Completed digital_clock --- digital-clock/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/digital-clock/main.py b/digital-clock/main.py index 986773e..14b5ebb 100644 --- a/digital-clock/main.py +++ b/digital-clock/main.py @@ -6,6 +6,8 @@ def get_current_time(): # TODO: Return the current system time in formatted string + print (datetime.now()) + pass def main(): @@ -14,6 +16,8 @@ def main(): try: while True: # Get current time and display it + get_current_time() + time.sleep(1) # Use time.sleep(1) to update every second pass except KeyboardInterrupt: From 33a59e9a9996a8c1db1632c82c96a2936d024a5a Mon Sep 17 00:00:00 2001 From: Enginneer887766 <70516735+Enginneer887766@users.noreply.github.com> Date: Sat, 20 Sep 2025 10:13:08 +0530 Subject: [PATCH 4/6] Completed color_picker --- pick-color/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pick-color/main.py b/pick-color/main.py index 4286499..0a2c51b 100644 --- a/pick-color/main.py +++ b/pick-color/main.py @@ -1,11 +1,12 @@ # Color Picker Simulator # Picks a random color from a predefined list -import random +from random import randrange def get_random_color(): # TODO: Return a random color from the list colors = ["Red", "Green", "Blue", "Yellow", "Purple", "Orange"] + print(colors[randrange(5)]) pass def main(): @@ -14,6 +15,6 @@ def main(): while True: input("Press Enter to pick a color (or Ctrl+C to quit)...") # Call the random color function and display the result - + print(get_random_color()) if __name__ == "__main__": main() From 97e392ffb558deb7e8bd85e2a2e06effcb088c4c Mon Sep 17 00:00:00 2001 From: Enginneer887766 <70516735+Enginneer887766@users.noreply.github.com> Date: Sat, 20 Sep 2025 10:22:37 +0530 Subject: [PATCH 5/6] Completed to do list --- to-do/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/to-do/main.py b/to-do/main.py index a1fcc80..b6b158e 100644 --- a/to-do/main.py +++ b/to-do/main.py @@ -9,14 +9,18 @@ def show_menu(): print("4. Exit") def add_task(tasks): + task = input("Enter a task") + tasks.append(task) # TODO: Ask user for a task and append to the list pass def remove_task(tasks): + tasks.pop() # TODO: Show task list and allow user to remove by index pass def view_tasks(tasks): + print(tasks) # TODO: Display current list of tasks pass From 1816e0e3edb9eadbe194078214152fe622da6a27 Mon Sep 17 00:00:00 2001 From: Enginneer887766 <70516735+Enginneer887766@users.noreply.github.com> Date: Tue, 23 Sep 2025 06:10:44 +0530 Subject: [PATCH 6/6] Update main.py --- calculator/main.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/calculator/main.py b/calculator/main.py index 43bf23b..c88ab2e 100644 --- a/calculator/main.py +++ b/calculator/main.py @@ -2,21 +2,23 @@ # Performs basic arithmetic operations based on user input def add(a, b): - # TODO: Return sum of a and b - pass + # Return sum of a and b + return a + b def subtract(a, b): - # TODO: Return difference of a and b - pass + # Return difference of a and b + return a - b def multiply(a, b): - # TODO: Return product of a and b - pass + # Return product of a and b + return a * b def divide(a, b): - # TODO: Return quotient of a and b + # Return quotient of a and b # Handle division by zero - pass + if b == 0: + return "Error: Division by zero!" + return a / b def main(): print("Simple Calculator") @@ -27,7 +29,18 @@ def main(): operator = input("Enter operator: ") num2 = float(input("Enter second number: ")) - # Match the operator with the correct function + if operator == '+': + result = add(num1, num2) + elif operator == '-': + result = subtract(num1, num2) + elif operator == '*': + result = multiply(num1, num2) + elif operator == '/': + result = divide(num1, num2) + else: + result = "Invalid operator!" + + print("Result:", result) except ValueError: print("Invalid number entered.")