ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(bool(0.0), bool(-0.0), bool(float('nan')), bool(' '), bool('0'), bool(0j))- A. False False True True True True
- B. False True True True True False
- C. False False True True True False
- D. False False True False True False
Correct answer: C. False False True True True False
Only zero of any numeric type is falsy, and -0.0 is also zero. NaN is truthy because it is not equal to 0. A string is falsy only when it is empty, so ' ' and '0' are both truthy.
More Python Programming questions
- What is printed? python s1 = 'u00e9' s2 = 'eu0301' print(s1 == s2, len(s1), len(s2), len(s2.encode()), s2 == 'eu0301')
- What is printed? python print(len('héllo'.encode('utf-8')), len('héllo'.encode('utf-16')), len('héllo'))
- What is printed? python print('abc' < 'abd', 'Z' < 'a', '10' < '9', [10] < [9], (1, 'b') < (1, 'a'))
- What is printed on the second line? python print(''.join(sorted('banana'))) print(sorted('Banana', key=str.lower)) print(sorted(['b10'…
- What is printed? python print(min([3, 1.0, True]), max([1, True, 1.0]), max([True, 1.0]), min([1.0, True]))
- What is printed? python print(list(range(10, 0, -3)), range(0, 10, 3)[-1], len(range(5, 1)), range(3) == range(0, 3, 1), range(0, 6, 2) ==…