Friday , September 20 2024

What will be the output of the following code, located in the p.py file? print(__name__)

Questions BankCategory: Python Essentials 2What will be the output of the following code, located in the p.py file? print(__name__)
What will be the output of the following code, located in the p.py file?

print(__name__)
  • main
  • __p.py__
  • p.py
  • __main__

Explanation: The __name__ variable is a built-in variable, which evaluates to the name of the current module being executed in the form of a string. Now, because the file is run directly, not imported, its __name__ variable is set to __main__.

More Questions: Python Essentials 2 (PE2) Course Final Test