Bird
0
0

What will be the output of this Lambda function when invoked with event {"numbers": [1,2,3]}?

medium📝 Predict Output Q5 of 15
AWS - Lambda
What will be the output of this Lambda function when invoked with event {"numbers": [1,2,3]}?
def handler(event, context):
    return sum(event['numbers'])
ANone
B6
CError: sum not defined
D[1,2,3]
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the function

    The function sums all elements in the list event['numbers'].
  2. Step 2: Calculate sum of [1,2,3]

    1 + 2 + 3 equals 6, so the function returns 6.
  3. Final Answer:

    6 -> Option B
  4. Quick Check:

    Sum of numbers list = 6 [OK]
Quick Trick: Sum list elements using sum() function [OK]
Common Mistakes:
MISTAKES
  • Returning the list instead of sum
  • Assuming sum is undefined
  • Returning None by mistake

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes