Variables, Types & Operators · Question 4 · Easy

Which of the following is a valid Python variable name?

  1. 2nd_rank
  2. total-marks
  3. class
  4. _score2
Answer and explanation

Answer: D. _score2

Explanation: A name may contain letters, digits and underscores but cannot start with a digit, so _score2 is valid. 2nd_rank starts with a digit, total-marks contains a minus sign, and class is a reserved keyword.

Previous: A roll number typed as text is converted before adding. What is printed? · Next: Which operator raises a number to a power in Python?

Practise variables, types & operators

Try a fresh set of variables, types & operators questions with an explanation after every answer, free and without signing up: Variables, Types & Operators practice. Or sit a full placement mock test.

More variables, types & operators questions

More python practice

Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge