ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
a = [1, 2, 3] b = a[:] a.append(4) print(len(a), len(b))
- A. 4 3
- B. 3 3
- C. 4 4
- D. 3 4
Correct answer: A. 4 3
a[:] creates a new list with three items. Appending to a does not change b.
More Python Programming questions
- What is printed? python print(list(filter(lambda s: s.startswith('a'), ['ab', 'ba', 'ac'])), ' a b '.strip().split(' '))
- What is the time complexity of x in d where d is a collections.deque of n items?
- What is printed? python x = 10 print(x.bitlength(), (x >> 1).bitlength(), (x << 3) // 16)
- What is printed? python words = ['tea', 'eat', 'tan', 'ate', 'nat'] groups = {} for w in words: groups.setdefault(''.join(sorted(w))…
- What is printed? python print(0.2 + 0.4 + 0.1 == 0.7, 0.1 + (0.2 + 0.4) == 0.7, 0.2 + 0.1 + 0.4 == 0.7)
- What is printed? python print(sorted([(1, 'b'), (1, 'a'), (0, 'z')], reverse=True)[0])