Robotics & Artificial Intelligence
Which out of the following is a valid variable name?
- @val
- 9val
- _val
- int
Getting Started
1 Like
Answer
_val
Reason — According to the rules for declaring variable names in Python, a variable name must start with a letter (capital or small) or an underscore (_). It can consist only of letters, digits, and underscore, variable names are case-sensitive, and Python keywords should not be used as variable names.
- @val — Invalid, because special characters like
@are not allowed in variable names. - 9val — Invalid, because a variable name cannot start with a digit.
- _val — Valid, because it starts with an underscore and follows all the rules of variable naming.
- int — Invalid, because
intis a Python keyword and keywords cannot be used as variable names.
Answered By
2 Likes
Related Questions
To define a dictionary in Python, which bracket is used?
- Curly{}
- Square[]
- Small()
- None of these
Consider the following statement and answer the question:
data = ("name": "Arjit", "age": 24)This statement:
- Will create a dictionary
- Will create a tuple
- Will produce an error
- Will create a set
The statement 5 % 4 will return …………… .
- 0
- 1
- 2
- 3
The statement 5 // 2 will return …………… .
- 2
- 2.5
- 5
- 0