x = int(input()) y = int(input()) x = x % y x = x % y y = y % x print(y)
- 1
- 2
- 3
- 4
Explanation: Let’s analyze this example:
the x variable is assigned the integer value of 11 (11 is inputted by the user, converted to a string by the input() function, and then converted to an integer by the int() function)
the y variable is assigned the integer value of 4 (4 is inputted by the user, converted to a string by the input() function, and then converted to an integer by the int() function)
an operation is performed resulting in the x variable being assigned the value of 3 (11 % 4 = 3)
an operation is performed resulting in the x variable being assigned the value of 0 (3 % 11 = 0)
an operation is performed resulting in the y variable being assigned the value of 1 (4 % 3 = 1)
the value assigned to the y variable (1) is printed to the screen.
More Questions: Python Essentials 1 – Module 2 Test
Please login or Register to submit your answer