ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(bool([]), bool([0]), bool(0.0), bool('False'), bool(None) or 'x')- A. False True False False x
- B. False True True True x
- C. False True False True x
- D. False False False True x
Correct answer: C. False True False True x
Only empty or zero-valued objects are false. [0] is a nonempty list, so it is true, and the non-empty string 'False' is also true. None is false, so the or returns 'x'.
More Python Programming questions
- What is printed? python import heapq events = [(3, 'end'), (1, 'start'), (2, 'mid')] heapq.heapify(events) out = [] while events: t, name…
- What is printed? python word = 'level' print(word == word[::-1], 'ab' 2 == 'abab', list('ab') == ['a', 'b'], ('a',) 0 == ())
- What is printed? python parent = list(range(5)) def find(x): while parent[x] != x: parent[x] = parent[parent[x]] x = parent[x] return x…
- What is printed? python trie = {} for w in ['car', 'cat', 'dog']: node = trie for ch in w: node = node.setdefault(ch, {}) node['#'] = True…
- What is printed? python h = 0 for ch in 'abc': h = (h 31 + ord(ch)) % 1000 print(h)
- What is printed? python grid = ['a..', '.a.', '...'] cnt = sum(row.count('.') for row in grid) diag = ''.join(grid[i][i] for i in…