Bird
0
0

Given this Python Lambda function:

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

What will the function return if the environment variable ENV is not defined?
A'production'
BNone
CAn error is raised
D'ENV'
Step-by-Step Solution
Solution:
  1. Step 1: Understand os.environ.get()

    The get method returns the value of the key if it exists, otherwise returns the default.
  2. Step 2: Check default value

    The default value provided is 'production'.
  3. Final Answer:

    'production' -> Option A
  4. Quick Check:

    os.environ.get returns default if key missing [OK]
Quick Trick: os.environ.get returns default if key missing [OK]
Common Mistakes:
  • Assuming None is returned when variable missing
  • Expecting an error if environment variable is absent
  • Confusing key name with returned value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes