Skip to content
4 changes: 3 additions & 1 deletion problems/easy/easy_q2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 :"))
Expand All @@ -45,4 +47,4 @@ def largest_of_two(a, b):





7 changes: 7 additions & 0 deletions problems/easy/easy_q3.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -35,6 +41,7 @@ def is_leap_year(year):




if __name__ == "__main__":

num = int(input("Enter the number :"))
Expand Down
18 changes: 16 additions & 2 deletions problems/easy/easy_q5.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -18,3 +31,4 @@ def grade_system(marks):
num = int(input("Enter the Mark : "))
res = grade_system(num)
print(res)
>>>>>>> c39895b92dbcd0dd59250c4268a660b41d857e3d
51 changes: 45 additions & 6 deletions problems/medium/m1.py
Original file line number Diff line number Diff line change
@@ -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: "))

Expand Down Expand Up @@ -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("-------------------------------------------------------")