ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(7 ** -1 * 7, (7 ** -1) * 7 == 1.0)
- A. 1 True
- B. 1.0 True
- C. 1.0 False
- D. 0.9999999999999999 True
Correct answer: B. 1.0 True
7 ** -1 is a float close to 1/7, and multiplying it by 7 rounds back to exactly 1.0 here. The power with a negative int exponent always gives a float.
More Python Programming questions
- What is printed? python print(int('0o777', 8) == 511, int('777', 8) - int('0o777', 0))
- What is printed? python print(len('%d' % -0), '%d' % -0.0, '%.1f' % -0.0)
- What is printed? python print(max('abc', 'abd', key=lambda s: s[::-1]), min('ba', 'ab', key=len))
- What is printed? python print(sorted([1, 10, 2], key=lambda x: str(x)[0]))
- What is printed? python print(0.1 + 0.1 == 0.2, 0.1 + 0.1 + 0.1 == 0.3, 0.2 + 0.2 == 0.4)
- What is printed? python print(list(range(2, 20, 5)), list(range(-1, -10, -4)))