Bird
0
0

What will this code print if the environment variable DEBUG_MODE is set to the string 'False' (note: string, not boolean)?

medium📝 Predict Output Q5 of 15
Flask - Deployment
What will this code print if the environment variable DEBUG_MODE is set to the string 'False' (note: string, not boolean)?
import os
debug = os.getenv('DEBUG_MODE', 'True')
print(debug == True)
AFalse
BTrue
CNone
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand os.getenv returns strings

    os.getenv returns the string 'False', not the boolean False.
  2. Step 2: Compare string 'False' to boolean True

    Comparing 'False' == True is False because types differ and values differ.
  3. Final Answer:

    False -> Option A
  4. Quick Check:

    Env vars are strings; string 'False' != boolean True [OK]
Quick Trick: Env vars are strings; compare carefully with booleans [OK]
Common Mistakes:
MISTAKES
  • Assuming 'False' string equals boolean False
  • Expecting True from string comparison
  • Ignoring type differences in comparison

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes