4. Python Variables Quiz

1. What is the correct way to assign an integer value 10 to a variable named my_number in Python?
Answer: my_number = 10
2. Is Python case-sensitive when it comes to variable names?
Answer: Yes
3. What happens if you try to use a variable that has not been assigned a value?
Answer: Python will raise a NameError.
4. Which of the following is an invalid variable name?
Answer: 1st_var
5. Which of the following statements about Python variable names is true?
Answer: Variable names can be of any length.
6. By convention, how do programmers indicate that a variable should be treated as a constant?
Answer: By writing the variable name entirely in uppercase.
7. Consider the following code. What will be the output?
x = 5
x = "Hello"
print(x)

Answer: Hello
8. What is the output of the following code?
x = 10
y = x
x = 20
print(y)
Answer: 10
9. What is the purpose of "del" statement in Python?
Answer: to delete a variable
10. What is a variable in Python?
Answer: A container to store values
Score: 0 / 0 answered