diff --git a/problems/easy/easy_q2.py b/problems/easy/easy_q2.py index c0c0c7c..ac0a9c6 100644 --- a/problems/easy/easy_q2.py +++ b/problems/easy/easy_q2.py @@ -37,6 +37,8 @@ def largest_of_two(a, b): return b print(num2,"larger") + + if __name__ == "__main__": num1 = int(input("Enter the First Number :")) num2 = int(input("Enter the Second :")) @@ -45,4 +47,4 @@ def largest_of_two(a, b): - + \ No newline at end of file diff --git a/problems/easy/easy_q3.py b/problems/easy/easy_q3.py index 33eded1..e874a42 100644 --- a/problems/easy/easy_q3.py +++ b/problems/easy/easy_q3.py @@ -1,6 +1,12 @@ # Leap Year or Not: Write a program to determine whether a given year is a leap year. def is_leap_year(year): + if year % 4 == 0 or year % 100 == 0 or year % 400 == 0: + return "Leap Year" + else: + return "Not a Leap Year" + + if year % 4 == 0: if year % 100 == 0: return "Not a Leap Year" @@ -35,6 +41,7 @@ def is_leap_year(year): + if __name__ == "__main__": num = int(input("Enter the number :")) diff --git a/problems/easy/easy_q5.py b/problems/easy/easy_q5.py index cec150a..794055c 100644 --- a/problems/easy/easy_q5.py +++ b/problems/easy/easy_q5.py @@ -1,6 +1,19 @@ -# Grading System: Write a program that takes a student’s marks as input and prints the grade (A, B, C, or F) based on given thresholds. - def grade_system(marks): +<<<<<<< HEAD + if marks >=90 and marks <=100: + return "A" + elif marks >= 80 and marks <=90: + return "B" + elif marks >= 70 and marks <=80: + return "C" + else: + return "D" + +if __name__ == "__main__": + num = int(input("Enter the Mark : ")) + res = grade_system(num) + print(res) +======= if marks >= 90: return "A" elif marks >= 80: @@ -18,3 +31,4 @@ def grade_system(marks): num = int(input("Enter the Mark : ")) res = grade_system(num) print(res) +>>>>>>> c39895b92dbcd0dd59250c4268a660b41d857e3d diff --git a/problems/medium/m1.py b/problems/medium/m1.py index 5a986f4..64ce7f8 100644 --- a/problems/medium/m1.py +++ b/problems/medium/m1.py @@ -1,11 +1,36 @@ -''' -Create a menu to perform basic mathematical operations (addition, subtraction, multiplication, division, modulo) on two numbers. - -''' def math_operations_menu(choice): - a, b = map(int, input("Enter two numbers(separated by commas): ").split(sep=",")) + try: + a, b = map(int, input("Enter two numbers (separated by a comma): ").split(sep=",")) + + # Perform the operation based on user's choice + if choice == 1: + print(f"Addition of {a} and {b}: {a + b}") + elif choice == 2: + print(f"Subtraction of {a} and {b}: {a - b}") + elif choice == 3: + print(f"Multiplication of {a} and {b}: {a * b}") + elif choice == 4: + if b == 0: + print("Error! Division by zero is not allowed.") + else: + print(f"Division of {a} and {b}: {a / b}") + elif choice == 5: + if b == 0: + print("Error! Modulo by zero is not allowed.") + else: + 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!!!") + 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: ")) @@ -52,14 +77,28 @@ def math_operations_menu(choice): print("Invalid option!!!") print("-------------Mathematical operation menu---------------") + 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("-------------------------------------------------------") - \ No newline at end of file + +