nerdexam
Python_Institute

PCEP-30-02 · Question #116

The digraph written as #! is used to:

The correct answer is B. tell a Unix or Unix-like OS how to execute the contents of a Python le. #! - called a shebang or hashbang - appears as the very first line of a script (e.g., #!/usr/bin/env python3) and tells the Unix/Linux kernel which interpreter to use when executing the file directly from the shell, making B correct. Option A is wrong because Windows does not…

Question

The digraph written as #! is used to:

Options

  • Atell an MS Windows OS how to execute the contents of a Python le.
  • Btell a Unix or Unix-like OS how to execute the contents of a Python le.
  • Ccreate a docstring.
  • Dmake a particular module entity a private one.

How the community answered

(47 responses)
  • A
    4% (2)
  • B
    77% (36)
  • C
    6% (3)
  • D
    13% (6)

Explanation

#! - called a shebang or hashbang - appears as the very first line of a script (e.g., #!/usr/bin/env python3) and tells the Unix/Linux kernel which interpreter to use when executing the file directly from the shell, making B correct. Option A is wrong because Windows does not recognize or use the shebang mechanism - it relies on file extensions and registry associations to determine how to run a file. Option C is wrong because docstrings are string literals (using """ or '''), not comments, and they document modules, functions, or classes. Option D is wrong because Python privacy conventions use a leading underscore (_name) or double underscore (__name) - the # character simply starts a comment, which the interpreter ignores entirely.

Memory tip: Think of #! as "hash-BANG" - it bangs (executes) the file on Unix. If you remember that Unix uses it and Windows doesn't, you'll never mix up A and B.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice