ProgrammingVery hardGATE CS · Product-company placement
What is printed?
What is printed?
print(chr(ord("a") + 25), ord("A") - ord("a"), "".join(chr(ord(c) ^ 32) for c in "PyThOn"), str(b"x", "ascii"))- A. y -32 pYtHoN x
- B. { -32 pYtHoN x
- C. z -32 PYTHON b'x'
- D. z -32 pYtHoN x
Correct answer: D. z -32 pYtHoN x
'a' + 25 is 'z'. Uppercase letters are 32 below lowercase in ASCII, and flipping bit 5 (XOR 32) swaps case. str(bytes, encoding) decodes rather than giving the repr.
More Python Programming questions
- What is printed? python print(min([], default=0), max([2, 7], default=0), min("b", "a", key=ord), sum([[1], [2]], []))
- What is printed? python for kw in [{}, {"strict": True}]: try: print(list(zip("ab", [1, 2, 3], kw)), end=" ") except ValueError…
- What is printed? python def g(): yield from range(2) yield from "ab" return "done" def h(): r = yield from g() yield r print(list(h())…
- What is printed? python def evens(): n = 0 while True: yield n n += 2 def take(k, it): return [next(it) for in range(k)] e = evens()…
- What is printed? python def pipeline(): nums = (n for n in range(10)) sq = (n n for n in nums if n % 2) big = (s for s in sq if s > 10)…
- What is printed? python def g(): print("a", end=" ") x = yield print("b", x, end=" ") yield x 2 it = g() print(it.send(None), end=" ")…