Variables Questions and Answers
Practice ModeShowing 10 of 24 questions
Q21
Which of these is a valid way to assign multiple variables in one line?
Answer: Option D
Explanation: Python allows multiple variable assignment in a single line.
Q22
What does the += operator do?
Answer: Option C
Explanation: The += operator adds the right operand to the left operand and assigns the result to the left operand.
Q23
How do you make a variable available inside a function without passing it as parameter?
Answer: Option A
Explanation: The global keyword allows access to global variables inside functions.
Q24
What is the output of: x = "hello"; print(x[1])?
Answer: Option B
Explanation: String indexing starts at 0, so index 1 refers to the second character.