Question

    What is the purpose of the "if __name__ == '__main__':" statement in a Python script?

    A It defines the main function of the script. Correct Answer Incorrect Answer
    B It checks if the script is being run as the main program. Correct Answer Incorrect Answer
    C It specifies the version of Python required to run the script. Correct Answer Incorrect Answer
    D It imports the required modules for the script. Correct Answer Incorrect Answer

    Solution

    It checks if the script is being run as the main program.

    Practice Next

    Relevant for Exams:

    ×
    ×