What happens if the same module is imported twice in one Python program?
Correct answer D. Its code runs only once; later imports reuse the cached module from sys.modules
Explanation
The import system first checks sys.modules, a cache of modules already loaded. If the module is there, the cached object is returned without executing the file again. To force a fresh execution during development you would use importlib.reload(), which re-executes the module code in place.
Answer checked How we write and check questions
Discussion