ProgrammingVery hardGATE CS · Product-company placement
What is printed?
What is printed?
print(max([1, 2], [1, 2, 0]), min("Z", "a", "_"), sorted([True, 0, -1, 0.5]), max(3, 3.0), max(3.0, 3))- A. [1, 2] _ [-1, 0, 0.5, True] 3.0 3
- B. [1, 2, 0] Z [-1, 0, 0.5, True] 3 3.0
- C. [1, 2, 0] _ [-1, 0, 0.5, 1] 3 3.0
- D. [1, 2, 0] Z [-1, 0, True, 0.5] 3.0 3.0
Correct answer: B. [1, 2, 0] Z [-1, 0, 0.5, True] 3 3.0
Lists compare lexicographically and a longer list with an equal prefix is larger. 'Z' (90) < '_' (95) < 'a' (97). True sorts as 1. On ties max returns the FIRST maximal argument, so 3 then 3.0.
More Python Programming questions
- What is printed? python print(bin(-5), (-5).bitlength(), ~5, -5 >> 1, -5 & 0b111, 5 ^ -1)
- What is printed? python print("10" + "5", int("10") + 5, "10" 2, str(10) 2 == "1010", "5" < "10")
- What is printed? python a = "hello" try: a[0] = "j" except TypeError: a = "j" + a[1:] b = a.replace("l", "X", 1) print(a, b…
- What is printed? python print(1000 == 1000, 0.1 + 0.7, 7 / 2 == 7 // 2 + 0.5, 2 0.5 2, (-8) (1 / 3) == -2)
- What is printed? python s = "racecar" print(s.index("c"), s.rindex("c"), s.find("c", 3), s[::-1] is s, s.count("a", 2))
- What is printed? python import sys print(type(10 20).name, 10 20 // 3 % 10, len(str(2 100)), (2 64) - 1 == 0xFFFFFFFFFFFFFFFF)