Bird
0
0

Given this Python Lambda handler code:

medium📝 Predict Output Q4 of 15
AWS - Lambda
Given this Python Lambda handler code:
def lambda_handler(event, context):
    return {'message': event['key']}

What will be the output if the event is {'key': 'hello'}?
ANone
B{'key': 'hello'}
CError: 'key' not found
D{'message': 'hello'}
Step-by-Step Solution
Solution:
  1. Step 1: Understand the event input and handler return

    The event dictionary has a key 'key' with value 'hello'. The handler returns a dictionary with 'message' key set to event['key'] value.
  2. Step 2: Substitute event['key'] with 'hello'

    Replacing event['key'] with 'hello' results in {'message': 'hello'} as the return value.
  3. Final Answer:

    {'message': 'hello'} -> Option D
  4. Quick Check:

    Return uses event['key'] value = {'message': 'hello'} [OK]
Quick Trick: Return dictionary with event key value [OK]
Common Mistakes:
  • Confusing keys in event dictionary
  • Expecting event itself as output
  • Missing quotes around string values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes