Python Operators
Python Operators - Important Points
21. | What is the output of the following code? x = 5 y = 2 print(x / y) |
---|
A. 2.5
B. 3
C. 2
D. 2.25
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The operator / performs floating-point division, which returns the quotient of the division as a floating-point number. In this case, 5 divided by 2 is equal to 2.5.
22. | What is the output of the following code? x = 5 y = 2 print(x > y) |
---|
A. 1
B. 0
C. Error
D. None of the above
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The operator > compares two values and returns True if the left operand is greater than the right operand, and False otherwise. In this case, 5 is greater than 2, so the output is True.
23. | What is the output of the following code? a = 10 b = 3 print(a % b) |
---|
A. 1
B. 3
C. 0
D. 10
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The % operator is used for modulo division in Python. It returns the remainder of the division. In this case, 10 % 3 is equal to 1.