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
107 changes: 0 additions & 107 deletions problems/medium/m1.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,110 +25,3 @@ def math_operations_menu(choice):
print("Invalid option!!!")
except ValueError:
print("Invalid input! Please enter two valid numbers separated by a comma.")


# Menu for mathematical operations
print("-------------Mathematical Operation Menu---------------")


a=int(input("Enter first numbers: "))
b=int(input("Enter second numbers: "))


if choice == 2:
print("Subtraction:", a - b)
elif choice == 1:
print("Addition:", a + b)

if choice == 1:

print(f"Addition of {a} and {b} : {a + b}")

print("Addition:", a + b)
elif choice == 2:
print("Subtration:", a - b)
elif choice == 3:
print("Multiplication:", a * b)
elif choice == 4:
print("Division:", a / b)
elif choice == 5:
print("Modulo:", a // b)
else:
print("Invalid option")

math_operations_menu()


if choice == 2:
print("Subtraction:", a - b)
elif choice == 1:
print("Addition:", a + b)

elif choice == 4:
print("Division:", a / b)
elif choice == 3:
print("Multiplication:", a * b)

if choice == 1:
print(f"Subtraction of {a} and {b}:{a - b}")

elif choice == 2:
print(f"Subtraction of {a} and {b} : {a - b}")
elif choice == 3:
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}")
else:
print("Invalid option")


math_operations_menu()

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")
print("4. Divide")
print("5. Modulus")

print("6. Exponential")

# Get user's choice for operation
try:
choice = int(input("Enter your choice: "))
math_operations_menu(choice)
except ValueError:
print("Invalid choice! Please enter a number between 1 and 6.")

print("-------------------------------------------------------")

print("6. Expontential")

choice = int(input("Enter your choice: "))
math_operations_menu(choice)
print("-------------------------------------------------------")




4 changes: 4 additions & 0 deletions problems/medium/m10.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def game_menu():
if choice == 1:
target = random.randint(1, 100)
guess = int(input("Guess a number between 1 and 100: "))

if guess = target:

if guess == target:

print("You won!")
else:
print("Try Again")
Expand Down
29 changes: 27 additions & 2 deletions problems/medium/m11.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Menu driven program to calculate perimeter and area of different shapes

def per_circle(radius):

perimeter = 3.14 * radius
print("Perimeter of Circle: ", perimeter)

def per_triangle(side1, side2, side3):
perimeter = side1 + side2 + side3

perimeter =2* 3.14 * radius
print("Perimeter of Circle: ", perimeter)

def per_triangle(side1, side2, side3):
perimeter = side1 + side2+ side3

print("Perimeter of Triangle: ", perimeter)

def per_rectangle(height, width):
Expand All @@ -22,17 +30,22 @@ def a_circle(radius):
print("Area of Circle: ", area)

def a_triangle(base, height):
area = base * height
area = 0.5 (base * height)
print("Area of Triangle: ", area)

def a_rectangle(height, width):
area = height * width
print("Area of Rectangle: ", area)

def a_square(side):

area = side * side

area = side *2

print("Area of Square: ", area)



print("\nWELCOME TO MENSURATION PROGRAM! TRY CALCULATING PERIMETER AND AREA OF DIFFERENT GEOMETRIC SHAPES.")


Expand Down Expand Up @@ -69,10 +82,17 @@ def a_square(side):
print("3. Exit")
choice1 = int(input("\nEnter choice for calculations: "))
if choice1 == 1:

side1 = int(input("Enter length of side1: "))
side2 = int(input("Enter length of side2: "))
side3 = int(input("Enter length of side3: "))
per_triangle(side1, side2, side3)

side1 = float(input("Enter length of side1: "))
side2 = float(input("Enter length of side2: "))
side3 = float(input("Enter length of side3: "))
per_triangle(side1,side2,side3)

elif choice1 == 2:
base = float(input("Enter base of triangle: "))
height = float(input("Enter height of triangle: "))
Expand All @@ -89,8 +109,13 @@ def a_square(side):
print("3. Exit")
choice1 = int(input("\nEnter choice for calculations: "))
if choice1 == 1:

height = int(input("Enter height of rectangle: "))
width = int(input("Enter width of rectangle: "))

height = float(input("Enter height of rectangle: "))
width = float(input("Enter width of rectangle: "))

per_rectangle(height,width)
elif choice1 == 2:
height = float(input("Enter height of rectangle: "))
Expand Down
17 changes: 13 additions & 4 deletions problems/medium/m13.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ def is_prime(num):
return False
return True

n = int(input("Enter a number: "))
for i in range(2, n + 1):
if is_prime(i):
print(i)
while True:
try:
n = int(input("Enter a number: "))
break
except:
print("Enter valid a integer.")


if is_prime(n):
print(f"{n} is a prime number.")
else:
print(f"{n} is not a prime number.")