1. 723 45.
314
2. 468 46. 591
3. 215 47. 806
4. 839 48. 452
5. 572 49. 739
6. 196 50. 605
7. 384
8. 907
9. 631
10. 402
11. 548
12. 179 def fibonacci(n):
13. 356
14. 824 fib_series = [0, 1]
15. 590 for i in range(2, n):
16. 137
17. 965 fib_series.append(fib_series[-1] +
18. 701 fib_series[-2])
19. 284
return fib_series
20. 436
21. 509 n = int(input("Enter the number of terms for
22. 673 Fibonacci series: "))
23. 821
print("Fibonacci series:", fibonacci(n))
24. 354
25. 687
26. 249
*********
27. 783
28. 102
29. 576
30. 943 def factorial(n):
31. 210 if n == 0:
32. 475
33. 816 return 1
34. 329 return n * factorial(n - 1)
35. 568
36. 917
37. 613
num = int(input("Enter a number to calculate
38. 495
factorial: "))
39. 728
40. 186 print("Factorial of", num, "is", factorial(num))
41. 537
42. 942
43. 260 *********
44. 874
def is_palindrome(string): consonants = 0
return string == string[::-1] for char in string.lower():
if char in 'aeiou':
word = input("Enter a word to check vowels += 1
palindrome: ")
elif char.isalpha():
print("Yes, it's a palindrome." if
consonants += 1
is_palindrome(word) else "No, it's not a
palindrome.") return vowels, consonants
**************** text = input("Enter a string to count vowels and
consonants: ")
vowels, consonants =
def reverse_string(string):
count_vowels_consonants(text)
return string[::-1]
print("Number of vowels:", vowels)
print("Number of consonants:", consonants)
word = input("Enter a string to reverse: ")
print("Reversed string:", reverse_string(word))
*************
*************
def find_max_min(arr):
if not arr:
def sum_of_digits(num):
return None, None
return sum(int(digit) for digit in str(num))
return max(arr), min(arr)
num = int(input("Enter a number to find the
numbers = list(map(int, input("Enter numbers
sum of its digits: "))
separated by space: ").split()))
print("Sum of digits:", sum_of_digits(num))
maximum, minimum = find_max_min(numbers)
print("Maximum:", maximum)
****************
print("Minimum:", minimum)
def count_vowels_consonants(string):
*************
vowels = 0
def is_armstrong(num): print("Yes, it's a perfect number." if
is_perfect(number) else "No, it's not a perfect
num_str = str(num)
number.")
num_digits = len(num_str)
return num == sum(int(digit) ** num_digits
*****************
for digit in num_str)
def is_leap_year(year):
number = int(input("Enter a number to check
Armstrong: ")) if year % 4 == 0:
print("Yes, it's an Armstrong number." if if year % 100 == 0:
is_armstrong(number) else "No, it's not an
if year % 400 == 0:
Armstrong number.")
return True
else:
**************
return False
else:
def is_palindrome_number(num):
return True
return str(num) == str(num)[::-1]
else:
return False
number = int(input("Enter a number to check
palindrome: "))
print("Yes, it's a palindrome number." if year = int(input("Enter a year to check leap
is_palindrome_number(number) else "No, it's year: "))
not a palindrome number.")
print("Yes, it's a leap year." if is_leap_year(year)
else "No, it's not a leap year.")
************************
def is_perfect(num):
factors_sum = sum(i for i in range(1, num) if
num % i == 0)
return factors_sum == num
number = int(input("Enter a number to check
perfect: "))