A file containing only the following line is run directly as a script. What is the output? print(__name__)
Correct answer C. __main__
Explanation
When a file is run directly as a script, the interpreter sets its module-level __name__ to the string "__main__". When the same file is imported, __name__ holds the module name instead. This is what makes the if __name__ == "__main__": idiom work.
Answer checked How we write and check questions
Discussion