nerdexam
Python_Institute

PCAP-31-03 · Question #74

Can a module run like regular code?

The correct answer is A. yes, and it can differentiate its behavior between the regular launch and import. it can differentiate its behavior between the regular launch and import Module have 2 users.One is the creator and other is the module users.The creator can execute his module and check the functionality using __name__ variable.Normal module users can execute the module by…

Technology and architecture

Question

Can a module run like regular code?

Options

  • Ayes, and it can differentiate its behavior between the regular launch and import
  • Bit depends on the Python version
  • Cyes, but it cannot differentiate its behavior between the regular launch and import
  • Dno. it is not possible; a module can be imported, not run

How the community answered

(14 responses)
  • A
    86% (12)
  • C
    7% (1)
  • D
    7% (1)

Explanation

it can differentiate its behavior between the regular launch and import Module have 2 users.One is the creator and other is the module users.The creator can execute his module and check the functionality using name variable.Normal module users can execute the module by using import.

Topics

#Python modules#module import#module execution#__name__ variable

Community Discussion

No community discussion yet for this question.

Full PCAP-31-03 Practice