menu

Python Operators

Python Operators - Important Points


16.

What is the output of the following code?

a = 2
b = 5
print(a * b ** 2)

A. 50

B. 35

C. 20

D. 10

Discuss Work Space

Answer: option a

Explanation:

The ** operator has higher precedence than the * operator. So, b ** 2 is evaluated first, which is 25. Then, 2 is multiplied with 25 to get the output 50.


17.

What is the output of the following code?

a = 5
b = 2
print(a % b)

A. 2.5

B. 2

C. 1

D. 0.5

Discuss Work Space

Answer: option c

Explanation:

The % operator returns the remainder of division between the first operand and the second operand. In this case, 5 divided by 2 gives 1 as remainder.


18.

What is the output of the following code?

x = 5
y = 2
print(x // y)

A. 2.5

B. 3

C. 2

D. 3

Discuss Work Space

Answer: option c

Explanation:

The operator // performs floor division, which returns the quotient of the division, rounded down to the nearest integer. In this case, 5 divided by 2 is equal to 2.5, but floor division returns only the integer part of the result, which is 2.


19. Which operator is used to perform exponentiation in Python?

A. **

B. ^

C. %

D. //

Discuss Work Space

Answer: option a

Explanation:

The operator ** is used for exponentiation in Python. It raises the first operand to the power of the second operanFor example, 2 ** 3 returns 8, which is 2 raised to the power of 3.

20.

What is the output of the following code?

x = 5
y = 2
print(x % y)

A. 2.5

B. 3

C. 2

D. 1

Discuss Work Space

Answer: option d

Explanation:

The operator % performs modulus division, which returns the remainder of the division. In this case, 5 divided by 2 has a remainder of 1, so the output is 1.



Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now