a. spam23
b. SPAM23
c. 23spam
d. spam_23
Which Of The Following Is A Bad Python Variable Name?
Ans. Option C) 23spam is the Correct Answer.
In Python, variable names must follow certain rules and conventions. Here are the rules and why each of the provided options is valid or not:
Variable Name Rules:
- Variable names must start with a letter (a-z, A-Z) or an underscore (_).
- Subsequent characters in the variable name can be letters, numbers, or underscores.
- Variable names are case-sensitive, meaning “spam” and “SPAM” are considered different variables.
Hence, Option C is the answer as it is not a valid variable name because it starts with a number (‘2’), violating the rule that variable names must begin with a letter.
Hello, I’m Hridhya Manoj. I’m passionate about technology and its ever-evolving landscape. With a deep love for writing and a curious mind, I enjoy translating complex concepts into understandable, engaging content. Let’s explore the world of tech together