10_assignment_
10_assignment_
1 Multiple Choice
1. c. Partial Argument
2. d. Allows mutable values only as argument.
3. d. Allows any type of value as argument.
4. d. Default argument allows non-default argument to follow default.
5. b. It cannot access global namespace variables.
sum_of_4_numbers = lambda a, b, c, d: a + b + c + d
import math
area_of_circle = lambda radius: math.pi * radius * radius
Q.6 Function to Find Maximum from Numbers Passed as Argument (Using Arbitrary
Argument)
def max_from_numbers(*args):
return max(args)
Q.7 Function to Find the Person Eligible to Vote (Using Arbitrary Keyword Argument)
def check_voter_eligibility(**details):
if details.get('age', 0) >= 18:
return f"{details.get('name', 'Person')} is eligible to vote."
else:
return f"{details.get('name', 'Person')} is not eligible to vote."
def sum_numeric_values(*args):
return sum(arg for arg in args if isinstance(arg, (int, float)))
def count_numbers_in_ranges(*args):
counts = {'< 0': 0, '0 - 50': 0, '51 - 100': 0, '> 100': 0}
for num in args:
if num < 0:
counts['< 0'] += 1
elif 0 <= num <= 50:
counts['0 - 50'] += 1
elif 51 <= num <= 100:
counts['51 - 100'] += 1
else:
counts['> 100'] += 1
return counts