ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(max(float('nan'), 1.0), min(float('nan'), 1.0), max(1.0, float('nan')))- A. 1.0 1.0 nan
- B. nan 1.0 nan
- C. nan nan nan
- D. nan nan 1.0
Correct answer: D. nan nan 1.0
max and min keep the current value unless the next item compares greater or smaller. Every comparison with NaN is False, so a NaN in the first position is never replaced, while a NaN in the second position is ignored.
More Python Programming questions
- What is printed? python print(len(str(3100)), str(3100)[-1], str(3100)[:3])
- What is printed? python s = 'x' t = s s = s + 'y' print(t, s, t is s)
- What is printed? python print(''.join(map(chr, [72, 105])), ord('A') > 127, len('ab'.encode('utf-8')))
- What is printed? python print(list('hi'.encode('utf-16-le')), len('hi'.encode('utf-32')))
- What is printed? python print(bytes([104, 105]).decode(), bytes(b'ab').hex(), bytes([10, 255]).hex())
- What is printed? python print(f'{0.1:.1f}', f'{0.25:.1f}', f'{0.35:.1f}', f'{0.45:.1f}')