Variables Questions and Answers

Practice Mode
Showing 10 of 24 questions
Q21
Which of these is a valid way to assign multiple variables in one line?
  • A a, b, c = 1, 2, 3
  • B a = b = c = 1
  • C a = 1; b = 2; c = 3
  • D All of the above
Answer: Option D
Explanation: Python allows multiple variable assignment in a single line.
Q22
What does the += operator do?
  • A Addition only
  • B Assignment only
  • C Addition and assignment
  • D Comparison
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?
  • A global keyword
  • B local keyword
  • C import keyword
  • D extern keyword
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])?
  • A h
  • B e
  • C l
  • D o
Answer: Option B
Explanation: String indexing starts at 0, so index 1 refers to the second character.
Questions and Answers for Competitive Exams Various Entrance Test