Bird
0
0

Given this AWS Lambda function code snippet in Python:

medium📝 Predict Output Q13 of 15
AWS - Lambda
Given this AWS Lambda function code snippet in Python:
def handler(event, context):
    return event.get('key', 'default')

What will be the output if the event is {}?
A"default"
BNone
CError
D"key"
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the handler function

    The function returns the value of 'key' from event, or 'default' if 'key' is missing.
  2. Step 2: Check the event input

    The event is an empty dictionary, so 'key' is not present, so it returns 'default'.
  3. Final Answer:

    "default" -> Option A
  4. Quick Check:

    Missing key returns default [OK]
Quick Trick: Missing dict key returns default value [OK]
Common Mistakes:
MISTAKES
  • Assuming missing key returns None
  • Expecting an error on missing key
  • Confusing key name with value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes