ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(float('3.0') == 3, int(float('3.9')), round(3.5) + round(4.5), 3 == 3.0 == 3)- A. True 3 9 False
- B. False 4 8 True
- C. True 3 8 True
- D. True 4 8 False
Correct answer: C. True 3 8 True
float('3.0') equals 3, and int(float('3.9')) truncates to 3. Round half to even gives 4 for 3.5 and 4 for 4.5, so the total is 8. Chained equality holds.
More Python Programming questions
- What is printed? python s = 'abc' 2 print(s.count('a'), s.index('c'), s[2::3], len(s.split('b')))
- What is printed? python print(list(map(len, ['ab', 'c', ''])), list(filter(None, [0, 1, '', 'a'])), any([]), all([]))
- What is printed? python print('%d items' % 3, '%s' % 3.0, '%s' % None, '%r' % None)
- What is printed? python print(10 3 == 1000.0, 1e3 == 10 3, type(10 3).name, type(1e3).name)
- What is printed? python print(bin(5), oct(8), hex(16), int('101', 2) + int('7', 8))
- What is printed? python print(sorted(['apple', 'Banana', 'cherry'], key=str.lower), sorted(['apple', 'Banana', 'cherry']))