ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(max(3, 3.0), max(3.0, 3), min(-0.0, 0), min(0, -0.0))
- A. 3 3.0 0.0 -0.0
- B. 3 3.0 -0.0 0
- C. 3.0 3 -0.0 0
- D. 3 3 -0.0 1
Correct answer: B. 3 3.0 -0.0 0
max and min return the first of equal values, so max(3, 3.0) is 3 and max(3.0, 3) is 3.0. min(-0.0, 0) returns -0.0 because the two compare equal and the first is kept.
More Python Programming questions
- What is printed? python print('abc'[1:][::-1], 'abc'[::-1][1:], 'abcdef'[::-2][:2])
- What is printed? python print(float('nan') != float('nan'), float('inf') == float('inf'), float('inf') - float('inf') == 0, -float('inf')…
- What is printed? python x = [1, 2, 3] y = x x = x + [4] print(y, x, y is x)
- What is printed? python print(int('٤٢'), '٤٢'.isnumeric(), ' 42n'.isdigit(), int('42n'))
- What is printed? python from collections import Counter c = Counter() c['a'] += 2 c.update('ab') print(c['a'], c['b'], c['z']…
- What is printed? python print(pow(2, 1018, 109 + 7) == pow(2, 1018 % (109 + 6), 109 + 7))