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
10 changes: 2 additions & 8 deletions problems/easy/easy_q1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@

num = int(input("Enter a number: "))


if (num % 2) == 0:
print("{0} is Even".format(num))
else:
print("{0} is Odd".format(num))

if (num % 2) != 0:
print("{0} is Odd".format(num))
else:
print("{0} is Even".format(num))




31 changes: 3 additions & 28 deletions problems/easy/easy_q2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,17 @@
def largest_of_two(a, b):
if a > b:


return a
else:
return b
if __name__ == "__main__":
num1 = int(input("Enter the First Number :"))
num2 = int(input("Enter the Second Number :"))
res = largest_of_two(num1,num2)
print(res)


print(num1,"larger")
else:
print(num2,"larger")

if __name__ == "__main__":
num1 = int(input("Enter the First Number :"))
num2 = int(input("Enter the Second :"))
res = largest_of_two(num1,num1)
print(res)


return a

return a

else:
return b
if __name__ == "__main__":
num1 = int(input("Enter the First Number :"))
num2 = int(input("Enter the Second Number :"))
res = largest_of_two(num1,num2)
keerthi
print("The Largest Number is",res)

print(res)


main



9 changes: 2 additions & 7 deletions problems/easy/easy_q3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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:
if year % 100 == 0:
return "Not a Leap Year"
Expand All @@ -21,10 +22,4 @@ def is_leap_year(year):

return "Leap Year"
return "Not a Leap Year"


if __name__ == "__main__":

num = int(input("Enter the number :"))
res = is_leap_year(num)
print(res)

3 changes: 2 additions & 1 deletion problems/easy/easy_q4.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
num = int(input("Enter the Number : "))

def check_number(num):

if num < 0:
print("Negative")
elif num > 0:
print("Positive")
else:

print("Number is Zero")

if __name__ == "__main__":
num = int(input("Enter the Number : "))
check_number(num)
Expand Down
9 changes: 8 additions & 1 deletion problems/easy/easy_q5.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ def grade_system(marks):
return "C"
else:

return "F"

if __name__ == "__main__":
mark = int(input("Enter the Mark : "))
res = grade_system(mark)


return "D"


if __name__ == "__main__":
num = int(input("Enter the Mark : "))
res = grade_system(num)
print(res)

3 changes: 1 addition & 2 deletions problems/easy/easy_q6.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ def print_numbers(n):
i = 1
while i <= n:
print(i)
i += 1


if __name__ == "__main__":
num = int(input("Enter the Number "))
print_numbers(num)
Expand Down
8 changes: 7 additions & 1 deletion problems/easy/easy_q7.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
# Sum of Digits: Write a program to calculate the sum of digits of a number using a while loop.
def sum_of_digits(num):
def sum_of_digits(num):
total = 0
while num > 0:
total += num % 10

num = num // 10


num = num // 10

num //= 10


return total

if __name__ == "__main__":
num = int(input("Enter the Number : "))

res=sum_of_digits(num)
print(res)





44 changes: 5 additions & 39 deletions problems/medium/m1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
def math_operations_menu(choice):
a, b = map(int, input("Enter two numbers(separated by commas): ").split(sep=","))


a=int(input("Enter a num1:"))
b=int(input("Enter a num2:"))



if choice == 1:
Expand All @@ -19,44 +23,6 @@ def math_operations_menu(choice):
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"Addition 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}")
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. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
print("5. Modulus")
print("6. Expontential")
choice = int(input("Enter your choice: "))
math_operations_menu(choice)
print("-------------------------------------------------------")