ProgrammingModerateGATE CS · Product-company placement
What is printed?
What is printed?
s = "The quick brown fox"
w = s.split()
print(" ".join(w[::-1]), " ".join(x[::-1] for x in w)[:9], max(w, key=len))- A. fox brown quick The ehT kciuq quick
- B. fox brown quick The ehT kciuq brown
- C. xof nworb kciuq ehT ehT kciuq quick
- D. fox brown quick The ehT kciu quick
Correct answer: A. fox brown quick The ehT kciuq quick
Reversing the word list reverses word order; reversing each word reverses its characters, and the first 9 characters are 'ehT kciuq'. max with key=len returns the FIRST longest word, 'quick' (tied with 'brown').
More Python Programming questions
- What is printed? python d = {} for w in "to be or not to be".split(): d[w] = d.get(w, 0) + 1 best = max(d, key=d.get) print(best…
- What is printed? python class Stack(list): def push(self, v): self.append(v) return self s = Stack() s.push(1).push(2) t = s + [3]…
- What is printed? (Output lines are shown separated by " / ".) python def f(, a, b=2): return a - b def g(a, b=2, /): return a - b…
- What is printed? python def outer(fn): def w(a, k): return fn(a, k) 2 return w class C: @outer def val(self, x): return x + 1 @property…
- What is printed? python def log(prefix): def deco(fn): def w(a): return prefix + str(fn(a)) return w return deco @log("A:") @log("B:") def…
- What is printed? python import functools def once(fn): done = [] @functools.wraps(fn) def w(a): if not done: done.append(fn(a)) return…