ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(list('ab') == ['a', 'b'], 'ab' == ['a', 'b'])- A. True True
- B. False False
- C. False True
- D. True False
Correct answer: D. True False
list('ab') builds the list of characters, so it equals ['a', 'b']. A string is never equal to a list.
More Python Programming questions
- What is printed? python print(len(dict.fromkeys('aab')), list(dict.fromkeys('aab')))
- What is printed? python print([x for x in [1, 2, 3] for in range(x)])
- What is printed? python print(sorted(['b10', 'b9', 'a100', 'c2'], key=lambda s: (s[0], int(s[1:]))))
- What is printed? python print(sorted([-2, 1, 2, -1], key=abs))
- What is printed? python print('%5.1f|%-5d|' % (3.14159, 42))
- What is printed? python print(max(range(7), key=lambda i: (i % 3, i)))