0
0
Pythonprogramming~20 mins

Naming rules and conventions in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Naming Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of variable naming with underscores
What is the output of this code snippet?
Python
my_var = 10
_myVar = 20
print(my_var + _myVar)
A30
B1020
CNameError
DSyntaxError
Attempts:
2 left
💡 Hint
Remember that variables starting with underscore are valid names.
Predict Output
intermediate
2:00remaining
Output with invalid variable name
What error does this code raise?
Python
2nd_var = 5
print(2nd_var)
ASyntaxError
BNameError
CTypeError
D5
Attempts:
2 left
💡 Hint
Variable names cannot start with a number.
Predict Output
advanced
2:00remaining
Output of variable naming with reserved keywords
What error does this code produce?
Python
class = 10
print(class)
ATypeError
BSyntaxError
C10
DNameError
Attempts:
2 left
💡 Hint
Reserved keywords cannot be used as variable names.
Predict Output
advanced
2:00remaining
Output of variable naming with case sensitivity
What is the output of this code?
Python
Var = 5
var = 10
print(Var + var)
A5
B10
C15
DNameError
Attempts:
2 left
💡 Hint
Python variable names are case sensitive.
🧠 Conceptual
expert
2:00remaining
Identify the valid variable names
Which of the following variable names are valid in Python? Select the one that is NOT valid.
A_myVar1
BmyVar_2
Cvar3
Dmy-var
Attempts:
2 left
💡 Hint
Variable names cannot contain hyphens.