ProgrammingHardGATE CS · Product-company placement
What is printed?
What is printed?
import sys print(type(10 ** 20).__name__, 10 ** 20 // 3 % 10, len(str(2 ** 100)), (2 ** 64) - 1 == 0xFFFF_FFFF_FFFF_FFFF)
- A. long 3 31 True
- B. int 3 30 True
- C. int 3 31 True
- D. OverflowError
Correct answer: C. int 3 31 True
index finds the first 'c' (2), rindex the last (4), and find with start 3 skips index 2 to find 4. The reversed slice is a new string object, so `is` is False. count from index 2 sees only the 'a' at index 5.
More Python Programming questions
- What is printed? python x = [1, 2, 3] print(x 2, [x] 2 == [[1, 2, 3], [1, 2, 3]], x + [4] is x, [] == False, not [])
- What is printed? python t = 1, 2, u = (3) v = () w = (4,) 0 print(type(t).name, len(t), type(u).name, v == w, (1, 2) < (1, 2, -1))
- What is printed? python class Err(Exception): def init(self, code): super().init(f"code {code}") self.code = code try: try: raise Err(7)…
- What is printed? python def check(v): assert v > 0, f"bad {v}" return v try: check(-1) except AssertionError as e: print("AE", e, end=" ")…
- What is printed? python it = iter([1, 2]) try: while True: print(next(it), end=" ") except StopIteration as e: print("stop", e.value…
- What is printed? python def f(): try: return [1] finally: pass def g(): x = [1] try: return x finally: x.append(2) def h(): x = 1 try…