menu

Python Operators

Python Operators - Important Points


6.

What is the output of the following code snippet?

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

A. 2.5

B. 2

C. 1.5

D. 1

Discuss Work Space

Answer: option d

Explanation:

The % operator performs modulus operation and returns the remainder when a is divided by In this case, 5%2 returns 1.


7.

What is the output of the following code snippet?

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

A. 6

B. 8

C. 9

D. 27

Discuss Work Space

Answer: option b

Explanation:

The ** operator performs exponentiation and returns a raised to the power of In this case, 2**3 returns 8.


8.

What is the output of the following code snippet?

a = 10
b = 5
print(a>b and a/b==2)

A. 1

B. 0

C. Syntax Error

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

The and operator returns True if both expressions are True. In this case, a>b is True and a/b==2 is also True, so the output is True.


9.

What is the output of the following code snippet?

a = 10
b = 5
print(a>b or a/b==2)

A. 1

B. 0

C. Syntax Error

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

The or operator returns True if at least one of the expressions is True. In this case, a>b is True but a/b==2 is False, so the output is true.


10.

What is the output of the following code snippet?

a = 3
b = 3
print(a is b)

A. 1

B. 0

C. Syntax Error

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

The is operator returns True if both operands refer to the same object.



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