Recall & Review
beginner
What characters can you use to start a variable name in Python?
A variable name must start with a letter (a-z, A-Z) or an underscore (_). It cannot start with a number or special character.
Click to reveal answer
beginner
Is the variable name
my-variable valid in Python? Why or why not?No, because the hyphen (-) is not allowed in variable names. Use underscores (_) instead, like
my_variable.Click to reveal answer
beginner
What is the naming convention for constants in Python?
Constants are usually written in all uppercase letters with underscores separating words, like
MAX_SPEED.Click to reveal answer
beginner
How should you name a function in Python according to conventions?
Function names should be lowercase with words separated by underscores, like
calculate_total.Click to reveal answer
beginner
Why should you avoid using Python reserved keywords as variable names?
Reserved keywords have special meaning in Python and using them as variable names will cause errors or unexpected behavior.
Click to reveal answer
Which of these is a valid Python variable name?
✗ Incorrect
Variable names cannot start with a number, contain hyphens, or spaces. Only 'user_name' is valid.
What is the correct way to name a constant in Python?
✗ Incorrect
Constants are written in all uppercase letters with underscores separating words.
Which of these is NOT allowed as a variable name in Python?
✗ Incorrect
'class' is a reserved keyword in Python and cannot be used as a variable name.
How should function names be written in Python?
✗ Incorrect
Function names use lowercase letters with underscores between words.
Which character is NOT allowed in Python variable names?
✗ Incorrect
Hyphens (-) are not allowed in variable names.
Explain the basic rules for naming variables in Python.
Think about what characters are allowed and what is not.
You got /4 concepts.
Describe the common naming conventions for constants and functions in Python.
Consider how uppercase and lowercase letters are used.
You got /3 concepts.