Which of the following statements are true? (Select two answers)

Which of the following statements are true? (Select two answers)
A . The ** operator uses right-sided binding.
B. The result of the / operator is always an integer value.
C. The right argument of the % operator cannot be zero.
D. Addition precedes multiplication.

Answer: B,D

Explanation:

Topics: exponentiation/power operator right-sided binding

Try it yourself:

print(4 ** 3 ** 2) # 262144

print(4 ** (3 ** 2)) # 262144

print(4 ** 9) # 262144

print(262144) # 262144

# print(7 % 0) # ZeroDivisionError

If you have more than one power operators

next to each other, the right one will be executed first. https://docs.python.org/3/reference/expressions.html#the-power-operator To check the rest of a modulo operation,

Python needs to divide the first operand by the second operand.

And like in a normal division, the second operand cannot be zero.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments