Single Choice Not Set

QWhich of the following is used to initialize multiple variables with a common value?

ID: #3392 Python Operator MCQ 616 views
Question Info
#3392Q ID
Not SetDifficulty
Python Operator MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A x = y: y = 33
  • B x = y = z = 33
  • C x = z; y = z; x = 33;
  • D x & y & z = 33
Correct Answer

Explanation

In Python, multiple variables can be initialized with the same value using a single assignment statement. This is done by chaining the assignment operator (=).

Example:

x = y = z = 33

print(x)
print(y)
print(z)

Output:

33
33
33

In this example, the value 33 is assigned to the variables x, y, and z simultaneously.

The other options are incorrect because they do not follow Python's syntax for assigning the same value to multiple variables.

Therefore, the correct answer is Option B) x = y = z = 33.

Share This Question

Challenge a friend or share with your study group.