ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(f"{3.14159:.2f}|{42:>5}|{'ab':*^6}|{255:#x}|{1234567:,}")- A. 3.14|42 |**ab**|0xff|1,234,567
- B. 3.14| 42|ab****|ff|1,234,567
- C. 3.14| 42|**ab**|0xff|1,234,567
- D. 3.142| 42|**ab**|0xff|1234567
Correct answer: C. 3.14| 42|**ab**|0xff|1,234,567
.2f rounds to two decimals; >5 right-aligns in width 5 (3 spaces then 42); *^6 centres 'ab' in width 6 with * fill; #x is hexadecimal with the 0x prefix; the , option inserts thousands separators.
More Python Programming questions
- What is printed? python grid = [[0, 0]] 2 copy1 = list(grid) copy2 = [row[:] for row in grid] grid[0][0] = 1 grid[1] = [5, 5] print(copy1…
- What is printed? python vals = iter([3, 1, 0, 4, 0]) print(list(iter(lambda: next(vals), 0)), list(vals))
- What is printed? python class Acc: def init(self): self.items = [] def iadd(self, v): self.items.append(v) a = Acc() b = a a += 1 print(a…
- What is printed? python def f(): log = [] try: log.append("t") raise ValueError("v") except ValueError as e: log.append("e") raise…
- What is printed? python it = iter(range(10)) print(5 in it, next(it), 2 in it, list(it), 9 in range(10))
- What is printed? python calls = [] def chk(x): calls.append(x) return x > 2 r1 = any(chk(x) for x in [1, 3, 5]) r2 = all([chk(x) for x in…