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
7 changes: 4 additions & 3 deletions FunProjects/arrayCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ def comp(array1, array2):
return False


if (sorted(array1) == sorted([i ** 2 for i in array2])) and (sorted(array2) == sorted([i ** 2 for i in array1])):
if (sorted(array1) == sorted([i ** 2 for i in array2])) or (sorted(array2) == sorted([i ** 2 for i in array1])):
return True

return False


comp([1,2,3,4], [1,4,9,16])
lis1=eval(input("Enter list 1: "))
lis2=eval(input("Enter list 2: "))
print(comp(lis1,lis2))
9 changes: 9 additions & 0 deletions problems/easy/easy_q10.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Check Palindrome Number: Use a do-while loop to determine if a given number is a palindrome
def is_palindrome(num):
original = num

reverse = 0
while num != 0:
reverse = reverse * 10 + num % 10
num //= 10

return reverse == original

reverse = ''
while num != 0 :
reverse += str(num % 10)
Expand All @@ -9,6 +17,7 @@ def is_palindrome(num):
return "It is a Palindrome"
else:
return "It is not a Palindrome"

if __name__ == "__main__":
nums = int(input("Enter the Number: "))
res = is_palindrome(nums)
Expand Down
9 changes: 9 additions & 0 deletions problems/easy/easy_q11.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ def day_of_week(day):
}
return switch[day]
if __name__ == "__main__":

day=int(input("Enter the number : "))
if 0<day<8:
xcd = day_of_week(day)
print(xcd)
else:
print("Enter a valid input :")

day=int(input("Enter The Number:"))
if str(day) in "1234567":
xcd = day_of_week(day)
print(xcd)
else:
print("Enter Valid Input")


7 changes: 5 additions & 2 deletions problems/easy/easy_q12.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ def calculator(a, b, operator):
'*': a * b,
'/': a / b
}
return switch.get(operator, "Invalid Operator")
return switch.get(operator , "Invalid Operator")

if __name__ == "__main__":
n1 = int(input("Enter the Number 1 :"))
n2 = int(input("Enter the Number 2 :"))
opr = input("Enter the Operator :")
result = calculator(n1,n2,opr)
print(result)
print(result)

print(result)

10 changes: 10 additions & 0 deletions problems/easy/easy_q2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
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")
Expand Down Expand Up @@ -31,3 +40,4 @@ def largest_of_two(a, b):

main


11 changes: 11 additions & 0 deletions problems/easy/easy_q3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ def is_leap_year(year):
return "Leap Year"

if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:


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

return " Leap Year"
else:
return "not a Leap Year"


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


if __name__ == "__main__":

num = int(input("Enter the number :"))
Expand Down
5 changes: 5 additions & 0 deletions problems/easy/easy_q6.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ def print_numbers(n):
i += 1

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


num = int(input("Enter the Number :"))
print_numbers(num)

8 changes: 8 additions & 0 deletions problems/easy/easy_q7.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ def sum_of_digits(num):
total = 0
while num > 0:
total += 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)




7 changes: 5 additions & 2 deletions problems/easy/easy_q9.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ def factorial(n):

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

print(factorial(num))

res=factorial(num)
print(res)

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


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:
Expand All @@ -13,11 +23,14 @@ def math_operations_menu(choice):
print(f"Division of {a} and {b}:{a / b}")
elif choice == 4:
print(f"Multiplication of {a} and {b}:{a * b}")
elif choice == 5:
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")
Expand All @@ -28,4 +41,5 @@ def math_operations_menu(choice):
print("6. Expontential")
choice = int(input("Enter your choice: "))
math_operations_menu(choice)
print("-------------------------------------------------------")
print("-------------------------------------------------------")

7 changes: 7 additions & 0 deletions problems/medium/m2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ def array_operations_menu():
print("Smallest Element:", min(arr))
elif choice == 4:
arr.sort()

print("Sorted Array:", arr)
else:
print("Invalid option")
array_operations_menu()

print("Sorted Array:",arr)
else:
print("Invalid option")
array_operations_menu()


9 changes: 5 additions & 4 deletions problems/medium/m3.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ def string_manipulation_menu():
count = 0
for char in s:
if char in vowels:
count -= 1
count += 1
print("Number of Vowels:", count)
elif choice == 2:
print("Reversed String:", s[1::-1])
print("Reversed String:", s[::-1])
elif choice == 3:
if s[::-1] != s:
if s[::-1] == s:
print("Palindrome")
else:
print("Not a Palindrome")
elif choice == 4:
old = input("Substring to replace: ")
new = input("Replacement substring: ")
print("Updated String:", s)
print("Updated String:", s.replace(old,new))
else:
print("Invalid option")
string_manipulation_menu()
14 changes: 9 additions & 5 deletions problems/medium/m4.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,26 @@ def number_analysis_menu():
for i in range(2, n):
if n % i == 0:
is_prime = False
print("Not Prime")
if is_prime:
print("Prime")
else:
print("Not prime")
elif choice == 2:
factorial = 1
for i in range(1, n + 1):
factorial -= i
factorial *= i
print("Factorial:", factorial)
elif choice == 3:
fib = [0, 1]
for i in range(2, n + 1):
for i in range(2, n):
fib.append(fib[-1] + fib[-2])
print("Fibonacci Sequence:", fib[:-1])
print("Fibonacci Sequence:", fib)
elif choice == 4:
total = 0
while n > 0:
total += n % 10
n *= 10
n //= 10
print("Sum of Digits:", total)
else:
print("Invalid option")
number_analysis_menu()