QUESTION IMAGE
Question
what is the output of the following code?
x = 20
y = 6
print(x % y)
Step1: Understand the modulus operator
The % operator in Python returns the remainder of the division of the left operand by the right operand.
Step2: Calculate the remainder
We have \(x = 20\) and \(y=6\). When we divide \(20\) by \(6\), \(20 = 6\times3+2\). So \(20\%6\) gives the remainder \(2\).
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
A. 2