ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(7 ** -1 == 1 / 7, pow(7, -1, 13) * 7 % 13, (7 ** 2) % 13, 2 ** 3 ** 2 % 10)
- A. False 1 10 2
- B. True 1 10 8
- C. True 1 10 2
- D. True 2 10 2
Correct answer: C. True 1 10 2
7 ** -1 is computed as a float, the same as 1 / 7. The inverse of 7 mod 13 is 2 since 14 is 1 mod 13. ** is right-associative, so 2 ** 3 ** 2 is 2 ** 9 = 512, which ends in 2.
More Python Programming questions
- What is printed? python x = [0] 3 x[0] += 1 y = [[0]] 2 y[0][0] += 1 print(x, y)
- What is printed? python print(int(float('1e16')) + 1, float(int(260) + 1) == float(260))
- What is printed? python print('a-bc d'.split('-'), 'a-bc d'.replace('-', ' ').split(''), 'a-b'.partition('-')[0])
- What is printed? python print(sum([1] 105) == 105, sum([0.5] 105) == 5e4, 1/3 + 1/3 + 1/3 == 1.0, 0.7 + 0.2 + 0.1 == 1.0)
- What is printed? python from fractions import Fraction print(Fraction(7, 3) > 2, float(Fraction(7, 3)), Fraction(7, 3) // 1, Fraction(-7…
- What is printed? python print(1 + 2 3 2 // 4 % 5, (1 + 2) 3 2 // 4 % 5, -2 2, (-2) 2)