diff --git a/problems/medium/m1.py b/problems/medium/m1.py index a4685d2..1a29460 100644 --- a/problems/medium/m1.py +++ b/problems/medium/m1.py @@ -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("-------------------------------------------------------") - - - - diff --git a/problems/medium/m10.py b/problems/medium/m10.py index a8046f3..8cfcd14 100644 --- a/problems/medium/m10.py +++ b/problems/medium/m10.py @@ -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") diff --git a/problems/medium/m11.py b/problems/medium/m11.py index e09e520..0429420 100644 --- a/problems/medium/m11.py +++ b/problems/medium/m11.py @@ -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): @@ -22,7 +30,7 @@ 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): @@ -30,9 +38,14 @@ def a_rectangle(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.") @@ -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: ")) @@ -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: ")) diff --git a/problems/medium/m13.py b/problems/medium/m13.py index 33dfa3f..5751959 100644 --- a/problems/medium/m13.py +++ b/problems/medium/m13.py @@ -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.") + \ No newline at end of file