ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
import math print(math.sqrt(16), math.sqrt(2) ** 2 == 2, math.isqrt(2) ** 2 == 2, math.pow(2, 0.5) == 2 ** 0.5)
- A. 4.0 False False True
- B. 4.0 True False True
- C. 4 False False True
- D. 4.0 False True True
Correct answer: A. 4.0 False False True
sqrt returns a float, so 16 becomes 4.0. The square root of 2 is not exact in binary, so squaring it misses 2, and isqrt(2) is the integer 1, which squares to 1.
More Python Programming questions
- What is printed? python print(int(0.1 10) == 1, int(0.7 10), int(4.35 100), round(4.35 100))
- What is printed? python print(len(str(264)), 264 // 1019, 264 % 1019, len(str(264 - 1)))
- What is printed? python print(-7 // 2 2 + -7 % 2 == -7, 7 // -2 -2 + 7 % -2 == 7, -(-7 // 2))
- What is printed? python x = 0b1011 print(bin(x << 3), bin(x >> 1), x << 3 >> 3 == x, bin(~x & 0b1111))
- What is printed? python print(3 'ab' == 'ab' 3, 'ab' 3 == 'aba' + 'bab', [0] 3 == [0, 0, 0], ['a'] 2 == 'aa')
- What is printed? python s = 'The Quick' print(s.lower().split(), s.split('Q')[0].strip(), s[s.index(' ') + 1:], s.title().swapcase())