ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(hash(1.5) == hash(3/2), hash(True) == hash(1), {0: 'x', False: 'y'}, len({1: 'a', True: 'b', 1.0: 'c'}))- A. True False {0: 'x'} 1
- B. True True {0: 'y'} 1
- C. True True {0: 'x'} 3
- D. False True {0: 'y'} 1
Correct answer: B. True True {0: 'y'} 1
Equal numbers hash equal, so the two hash checks are True. False equals 0, so it overwrites the value for key 0 but keeps the original key object. 1, True and 1.0 are one key.
More Python Programming questions
- What is printed? python print(min(3, 2.0, True), max(1, 1.0), max(1.0, 1))
- What is printed? python print(253 == float(253), 253 + 1 == float(253 + 1), 253 + 2 == float(253 + 2))
- What is printed? python s = 'atbnc' print(len(s), s.split(), s.split('n'), repr(s.split()[0]))
- What is printed? python from fractions import Fraction print(Fraction(3, 6), Fraction('0.75'), Fraction(0.75), Fraction(1, 3) +…
- What is printed? python print(divmod(7, 2.5), divmod(-7.5, 2))
- What is printed? python print(0.1 + 0.1 + 0.1 == 0.3, 0.1 + 0.1 + 0.1, 0.3 == 3 0.1)