nerdexam
Python_Institute

PCEP-30-02 · Question #159

By which variable of the sys module can we access command line arguments?

The correct answer is D. argv. sys.argv is the correct variable - it's a list where argv[0] is the script name and subsequent indices hold any command-line arguments passed to it. The distractors are all plausible-sounding but don't exist in the sys module: argsv (option A) is simply a misspelling of argv…

Question

By which variable of the sys module can we access command line arguments?

Options

  • Aargsv
  • Barguments
  • Cargs
  • Dargv

How the community answered

(31 responses)
  • A
    3% (1)
  • B
    13% (4)
  • C
    10% (3)
  • D
    74% (23)

Explanation

sys.argv is the correct variable - it's a list where argv[0] is the script name and subsequent indices hold any command-line arguments passed to it. The distractors are all plausible-sounding but don't exist in the sys module: argsv (option A) is simply a misspelling of argv, arguments (option B) is JavaScript's keyword for accessing function arguments, and args (option C) is a common variable name used in custom code (e.g., from argparse) but is not a built-in sys attribute. Memory tip: argv mirrors C's int main(int argc, char *argv[]) - Python borrowed the name directly from C, so if you remember that argv means "argument vector," you'll never confuse it with the alternatives.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice