nerdexam
Python_Institute

PCEP-30-02 · Question #181

Which of the literals below is not a valid function name?

The correct answer is D. 1function. Option D (1function) is invalid because identifiers in most programming languages cannot begin with a digit - names must start with a letter or underscore. Options A (Function_1), B (Function1), C (_function1), and E (Func_1_tion) are all valid because they each start with…

Question

Which of the literals below is not a valid function name?

Options

  • AFunction_1
  • BFunction1
  • C_function1
  • D1function
  • EFunc_1_tion

How the community answered

(61 responses)
  • A
    3% (2)
  • B
    3% (2)
  • C
    2% (1)
  • D
    84% (51)
  • E
    8% (5)

Explanation

Option D (1function) is invalid because identifiers in most programming languages cannot begin with a digit - names must start with a letter or underscore. Options A (Function_1), B (Function1), C (_function1), and E (Func_1_tion) are all valid because they each start with either a letter or an underscore, and contain only letters, digits, and underscores thereafter. The key rule is about the first character: digits are allowed anywhere in a name except the very beginning.

Memory tip: Think "letters and underscores lead, digits follow" - if a name starts with a number, it's dead on arrival.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice