Functions Question Practical 1111
Functions Question Practical 1111
def check_even_odd(num):
if num % 2 == 0:
return "Even"
else:
return "Odd"
def factorial(n):
result = 1
for i in range(1, n + 1):
result *= i
return result
print(factorial(5))
# Output: 120
The loop multiplies numbers from 1 to n.
Answer:
def is_palindrome(s):
return s == s[::-1]
print(is_palindrome("Madam"))
# Output: True
Explanation:
def find_largest(numbers): .split() breaks that string into separate words (based on spaces) and gives a list of strings.
👉 Example: If user types 5 10 15, input().split() will return ['5', '10', '15'] (list of strings).
return max(numbers) 2. map(int, [...])
def find_smallest(numbers): map(int, ...) applies the int() function to each item in the list.
It converts each string like '5', '10', '15' into integers 5, 10, 15.
return min(numbers) 👉 After map(int, ...), you get something like: map object that acts like [5, 10, 15] (numbers now).