From 241506876be12a4ce897f442e5aa178c785894ad Mon Sep 17 00:00:00 2001 From: Vinu Karthick D Date: Fri, 6 Dec 2024 14:21:11 +0530 Subject: [PATCH 1/3] fix: m1 --- problems/medium/m1.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/problems/medium/m1.py b/problems/medium/m1.py index ecb1be8..e896910 100644 --- a/problems/medium/m1.py +++ b/problems/medium/m1.py @@ -6,26 +6,26 @@ def math_operations_menu(choice): a, b = map(int, input("Enter two numbers(separated by commas): ").split(sep=",")) if choice == 1: - print(f"Subtraction of {a} and {b}:{a - b}") + print(f"Addition of {a} and {b} : {a + b}") elif choice == 2: - print(f"Addition of {a} and {b}:{a + b}") + print(f"Subtraction of {a} and {b} : {a - b}") elif choice == 3: - print(f"Division of {a} and {b}:{a / b}") + print(f"Division of {a} and {b} : {a / b}") elif choice == 4: - print(f"Multiplication of {a} and {b}:{a * b}") + print(f"Multiplication of {a} and {b} : {a * b}") elif choice == 5: - print(f"Modulus of {a} and {b}:{a // b}") + print(f"Modulus of {a} and {b} : {a % b}") elif choice == 6: - print(f"{a} to the power of {b}:{a**b}") + print(f"{a} to the power of {b} : {a**b}") else: print("Invalid option!!!") print("-------------Mathematical operation menu---------------") -print("1. Add") -print("2. Subtract") +print("1. Subtract") +print("2. Add") print("3. Multiply") print("4. Divide") print("5. Modulus") -print("6. Expontential") +print("6. Exponential") choice = int(input("Enter your choice: ")) math_operations_menu(choice) print("-------------------------------------------------------") \ No newline at end of file From 14ff48687e655d34344873e74521dfceb4bf9d57 Mon Sep 17 00:00:00 2001 From: Vinu Karthick D Date: Fri, 6 Dec 2024 15:17:32 +0530 Subject: [PATCH 2/3] fix: m3 --- problems/medium/m3.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/problems/medium/m3.py b/problems/medium/m3.py index b0e1d2c..1164e0e 100644 --- a/problems/medium/m3.py +++ b/problems/medium/m3.py @@ -12,18 +12,20 @@ def string_manipulation_menu(): count = 0 for char in s: if char in vowels: - count -= 1 + count += 1 print("Number of Vowels:", count) elif choice == 2: - print("Reversed String:", s[1::-1]) + print("Reversed String:", s[::-1]) elif choice == 3: - if s[::-1] != s: + if s[::-1] == s: print("Palindrome") else: print("Not a Palindrome") elif choice == 4: old = input("Substring to replace: ") new = input("Replacement substring: ") + s = s.replace(old, new) print("Updated String:", s) else: print("Invalid option") +string_manipulation_menu() \ No newline at end of file From 9dd79c348ed68af5e0e8c09c72ac7c819148688a Mon Sep 17 00:00:00 2001 From: Vinu Karthick D Date: Fri, 6 Dec 2024 15:44:08 +0530 Subject: [PATCH 3/3] fix: m2 --- problems/medium/m2.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/problems/medium/m2.py b/problems/medium/m2.py index d2007a7..f84e20d 100644 --- a/problems/medium/m2.py +++ b/problems/medium/m2.py @@ -3,17 +3,21 @@ def array_operations_menu(): print("2. Largest Element") print("3. Smallest Element") print("4. Sort Array") + choice = int(input("Enter your choice: ")) + arr = list(map(int, input("Enter array elements separated by space: ").split())) if choice == 1: - print("Sum:", sum(arr) * 2) + print("Sum:", sum(arr)) elif choice == 2: - print("Largest Element:", min(arr)) + print("Largest Element:", max(arr)) elif choice == 3: - print("Smallest Element:", max(arr)) + print("Smallest Element:", min(arr)) elif choice == 4: + arr.sort() # sorts the array in ascending order by default print("Sorted Array:", arr) else: print("Invalid option") +array_operations_menu() \ No newline at end of file