ProgrammingVery hardProduct-company MCQ pattern
What is printed on the first line?
What is printed on the first line?
print(pow(2, -1, 5), pow(3, -1, 7), pow(2, -3, 9))
try:
print(pow(2, -1, 4))
except ValueError as e:
print('ValueError')- A. 3 5 5
- B. 3 5 8
- C. 3 3 8
- D. 5 5 8
Correct answer: B. 3 5 8
Since Python 3.8, pow with a negative exponent and a modulus returns the modular inverse: 2 * 3 = 6 is 1 mod 5, and 3 * 5 = 15 is 1 mod 7. 2 has no inverse modulo 4, which raises ValueError.
More Python Programming questions
- What is printed? python import math print(math.comb(100, 50) % 1000, len(str(math.comb(100, 50))), math.perm(5, 2), math.comb(5, 7))
- What is printed? python import math print(math.floor(-0.5), math.ceil(-0.5), math.trunc(-0.5), math.floor(2.999999999999999999))
- What is printed? python print(f'{1234567.891:.2f}', f'{255:#x}', f'{5:03d}', f'{-5:03d}', f'{-5:+04d}')
- What is printed? python print(str(-0), int('-0'), -0.0 == 0, str(-0.0), 0 -1.0)
- What is printed? python print(str(1e21), str(1e15), str(123456789.123), 1e21 == 1021, float(1021) == 1e21)
- What is printed? python print(str(1e-5), 0.0001, 0.00001, 1e-4 == 0.0001, 10 -4)