ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(max(3, 3.0), min(3.0, 3), max([2, 2.0]), type(max(2.0, 2)).__name__)
- A. 3.0 3 2 float
- B. 3 3.0 2.0 float
- C. 3 3.0 2 int
- D. 3 3.0 2 float
Correct answer: D. 3 3.0 2 float
max and min return the first item among equal values, so max(3, 3.0) is 3 and min(3.0, 3) is 3.0. max(2.0, 2) returns 2.0, which is a float.
More Python Programming questions
- What is printed? python print(sum([True, True, False]), sum([1.5, True]), True 3 + 0.5, sum([1, 2], 10))
- What is printed? python print(all([]), any([]), all([0, 1]), any([0.0, '']), all(x > 0 for x in [1, -1]))
- What is printed? python print(list(zip('ab', [1, 2, 3])), dict(zip('ab', [1, 2, 3])))
- What is printed? python print(sorted([('b', 1), ('a', 2), ('a', 1)])[1:], sorted({3: 'c', 1: 'a'}.items()))
- What is printed? python print(sorted({'b': 1, 'a': 2}), sorted({'b': 1, 'a': 2}.values(), reverse=True))
- What is printed? python print(len({x % 3 for x in range(10)}), sorted({x x % 5 for x in range(5)}))