Bird
0
0

Given this Python Lambda function code:

medium📝 Predict Output Q13 of 15
AWS - Lambda
Given this Python Lambda function code:
import os
def lambda_handler(event, context):
    return os.environ.get('MODE', 'default')

If the environment variable MODE is set to production, what will the function return?
A"default"
BNone
C"production"
DAn error occurs
Step-by-Step Solution
Solution:
  1. Step 1: Understand os.environ.get usage

    os.environ.get('MODE', 'default') returns the value of MODE if set, else 'default'.
  2. Step 2: Apply given environment variable

    Since MODE is set to 'production', the function returns 'production'.
  3. Final Answer:

    "production" -> Option C
  4. Quick Check:

    Env var MODE='production' returns 'production' [OK]
Quick Trick: os.environ.get returns env var value or default if missing [OK]
Common Mistakes:
  • Assuming default is always returned
  • Expecting None if variable exists
  • Thinking code throws error if env var exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes