diff --git a/problems/medium/m1.py b/problems/medium/m1.py index 64ce7f8..4e4a4a3 100644 --- a/problems/medium/m1.py +++ b/problems/medium/m1.py @@ -35,6 +35,9 @@ def math_operations_menu(choice): b=int(input("Enter second numbers: ")) if choice == 1: + + print(f"Addition of {a} and {b} : {a + b}") + print("Addition:", a + b) elif choice == 2: print("Subtration:", a - b) @@ -61,16 +64,22 @@ def math_operations_menu(choice): if choice == 1: print(f"Subtraction 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}") + elif choice == 5: + print(f"Modulus 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}") - elif choice == 6: - print(f"{a} to the power of {b}:{a**b}") + elif choice == 6: + print(f"{a} to the power of {b} : {a**b}") else: print("Invalid option") math_operations_menu() @@ -78,6 +87,14 @@ def math_operations_menu(choice): print("Invalid option!!!") print("-------------Mathematical operation menu---------------") +print("1. Subtract") +print("2. Add") +print("3. Multiply") +print("4. Divide") +print("5. Modulus") +print("6. Exponential") +======= + print("1. Add") print("2. Subtract") print("3. Multiply") @@ -96,6 +113,7 @@ def math_operations_menu(choice): print("-------------------------------------------------------") print("6. Expontential") + choice = int(input("Enter your choice: ")) math_operations_menu(choice) print("-------------------------------------------------------") diff --git a/problems/medium/m10.py b/problems/medium/m10.py index f70c55d..a8046f3 100644 --- a/problems/medium/m10.py +++ b/problems/medium/m10.py @@ -2,7 +2,7 @@ def game_menu(): while True: - print("\n1. Number Guessing Game") + print("1. Number Guessing Game") print("2. Rock-Paper-Scissors") print("3. Dice Roll Simulation") print("4. Exit") @@ -32,6 +32,9 @@ def game_menu(): else: print("Invalid Choice") +game_menu() + + x=input("Can we play some games?? (type yes and no)") if x=="yes": game_menu() @@ -40,4 +43,4 @@ def game_menu(): game_menu() - + \ No newline at end of file diff --git a/problems/medium/m2.py b/problems/medium/m2.py index 2b42991..e0f8021 100644 --- a/problems/medium/m2.py +++ b/problems/medium/m2.py @@ -3,8 +3,10 @@ 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: @@ -14,6 +16,13 @@ def array_operations_menu(): elif choice == 3: 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() + arr.sort() print("Sorted Array:", arr) @@ -25,5 +34,4 @@ def array_operations_menu(): else: print("Invalid option") array_operations_menu() - - + \ No newline at end of file diff --git a/problems/medium/m3.py b/problems/medium/m3.py index 5d5d7b8..045664c 100644 --- a/problems/medium/m3.py +++ b/problems/medium/m3.py @@ -24,7 +24,12 @@ def string_manipulation_menu(): elif choice == 4: old = input("Substring to replace: ") new = input("Replacement substring: ") + + s = s.replace(old, new) + print("Updated String:", s) + print("Updated String:", s.replace(old,new)) + else: print("Invalid option") string_manipulation_menu() \ No newline at end of file