Question 1
Q1A systems engineer is writing a Python script to automate the cleanup of temporary files across several Linux servers. The engineer defines a variable max_age_days = 30 at the very beginning of the script, outside of any functions. Inside a function named clean_temp_files(), the engineer attempts to reassign max_age_days = 15 without any additional keywords. What is the result of this action in Python?
Show answer & explanation
Correct answer: A
In Python, assigning a value to a variable inside a function creates a new local variable by default. To modify the global variable, the engineer would need to explicitly declare global max_age_days inside the function before assignment.