Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions problems/medium/m1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -61,23 +64,37 @@ 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()

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")
Expand All @@ -96,6 +113,7 @@ def math_operations_menu(choice):
print("-------------------------------------------------------")

print("6. Expontential")

choice = int(input("Enter your choice: "))
math_operations_menu(choice)
print("-------------------------------------------------------")
Expand Down
7 changes: 5 additions & 2 deletions problems/medium/m10.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand All @@ -40,4 +43,4 @@ def game_menu():


game_menu()

12 changes: 10 additions & 2 deletions problems/medium/m2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -25,5 +34,4 @@ def array_operations_menu():
else:
print("Invalid option")
array_operations_menu()



5 changes: 5 additions & 0 deletions problems/medium/m3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()