ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
a, *b, c = [1, 2, 3, 4] print(a, b, c)
- A. 1 [2, 3] 4
- B. 1 [2, 3, 4] 4
- C. 1 [2] 3
- D. 1 2 4
Correct answer: A. 1 [2, 3] 4
The starred target collects the middle items into a list. a takes the first item and c takes the last one.
More Python Programming questions
- What is printed? python print(12 & -12, 12 & 11, ~12 & 0xF)
- Which loop builds a list of n items in total O(n^2) time in CPython, because each step copies the whole list?
- What is printed? python s = {1, 2, 3} s |= {3, 4} s.discard(9) print(sorted(s), 4 in s, len(s))
- What is printed? python nums = [5, 3, 8] nums2 = nums nums += [1] nums3 = nums[:] nums3.pop() print(nums2, nums3)
- What is printed? python from math import gcd print(gcd(0, 5), gcd(-4, 6), gcd(0, 0))
- What is printed? python x = 12 x //= 5 y = 12 y /= 5 print(x, y, type(x).name, type(y).name)