ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(int(True) - ~True, 4 >> True, True << 3, True + True * True)
- A. 3 4 8 2
- B. 2 2 8 2
- C. 3 2 8 2
- D. 3 2 8 3
Correct answer: C. 3 2 8 2
True behaves as 1 in arithmetic and shifts, so ~True is -2 and the first value is 1 + 2 = 3. 4 >> 1 is 2, True << 3 is 8, and True + True * True is 2.
More Python Programming questions
- What is printed? python print('5' 3 > '10' 2, 5 3 > 10 2, '55' < '9', 55 < 9)
- What is printed? python print(float('inf') > 21000, -float('inf') < -(21000), float('inf') == float('inf') + 1)
- What is printed? python print(repr(0.1), repr(1 / 3), repr(2 / 3), repr(1e-7), repr(100.0))
- What is printed? python print(0.1 3 != 0.3, abs(0.1 3 - 0.3) < 2-52, abs(0.1 3 - 0.3) < 2-54)
- What is printed? python print(bin(255)[2:].rjust(10, '0'), int('0b' + '1' 8, 2) == 255, int('11111111', 2) + 0 == 255)
- What is printed? python s = 'hello world' print(s.count('o'), s.index('o', 5), s.title().split()[1][::-1])