Bird
0
0

What will the Lambda function return if event = {} in this code?

medium📝 Predict Output Q5 of 15
AWS - Lambda
What will the Lambda function return if event = {} in this code?
def lambda_handler(event, context):
    return event.get('status', 'No status provided')
A"No status provided"
BNone
CError: KeyError
D"status"
Step-by-Step Solution
Solution:
  1. Step 1: Check if 'status' key exists in event

    event is empty, so 'status' key is missing.
  2. Step 2: event.get returns default value

    Returns default string 'No status provided'.
  3. Final Answer:

    "No status provided" -> Option A
  4. Quick Check:

    Missing key returns default from get() [OK]
Quick Trick: event.get returns default if key missing [OK]
Common Mistakes:
  • Expecting None instead of default string
  • Confusing get() with direct dictionary access

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes