Quiz: Operators and Expression

To View Tricks: Login Required

Number of Questions: 12

Question: 6 -

What is the value of the following Python Expression

print(36 / 4)

Options:
  1. 0.9

  2. 9.0

  3. 9

  4. 0.09

  5. Answer:

    9.0

    Solution not available.

Question: 7 -

What is the output of the following addition (+) operator

a = [10, 20]
b = a
b += [30, 40]
print(a)
print(b)

Options:
  1. [10, 20, 30, 40]
    [10, 20, 30, 40]

  2. [30, 40]
    [10, 20, 30, 40]

  3. [10, 20]
    [10, 20, 30, 40]

    • [10, 30]
      [10, 20, 30, 40]
  4. Answer:

    [10, 20, 30, 40]
    [10, 20, 30, 40]

    Solution not available.

Question: 8 -

What is the output of the following assignment operator

y = 10
x = y += 2
print(x)

Options:
  1. 10

  2. 2

  3. Error

  4. 12

  5. Answer:

    Error

    Solution:

    x = y += 2 expression is Invalid


Question: 9 -

What is the output of print(2 * 3 ** 3 * 4)

Options:
  1. 816

  2. 216

  3. 864

  4. 256

  5. Answer:

    216

    Solution:

    The exponent (**) operator has higher precedence than multiplication (*). Therefore the statement print(2 * 3 ** 3 * 4) evaluates to print(2 * 27 * 4)


Question: 10 -

What is the output of print(2%6)

Options:
  1. 1

  2. ValueError

  3. 0.33

  4. 2

  5. Answer:

    2

    Solution:

    The first number is the numerator, and the second is the denominator. here, 2 is divided by 6. So the remainder is 2. Therefore the result is 2