Bird
0
0

Why might environment variables be preferred over hardcoding sensitive data like API keys in Python programs?

hard📝 Conceptual Q10 of 15
Python - Standard Library Usage
Why might environment variables be preferred over hardcoding sensitive data like API keys in Python programs?
AThey automatically encrypt the data
BThey make the program run faster
CThey keep sensitive data out of source code and version control
DThey allow changing data without restarting the program
Step-by-Step Solution
Solution:
  1. Step 1: Understand security benefits of environment variables

    Environment variables keep sensitive data like API keys outside source code, preventing accidental exposure in code repositories.
  2. Step 2: Evaluate other options

    They do not speed up programs, do not encrypt data automatically, and changes usually require restart.
  3. Final Answer:

    They keep sensitive data out of source code and version control -> Option C
  4. Quick Check:

    Env vars protect sensitive data = true [OK]
Quick Trick: Env vars keep secrets out of code and repos [OK]
Common Mistakes:
  • Thinking env vars encrypt data
  • Assuming env vars improve performance
  • Believing env vars update live without restart

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes