ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(10**20 / 10**19, 10**20 // 10**19, 2**64 % 1000, 10**20 == 1e20)
- A. 10.0 10 616 False
- B. 10 10 616 True
- C. 10.0 10 616 True
- D. 10.0 10 618 True
Correct answer: C. 10.0 10 616 True
/ always gives a float, while // keeps an int. 2^64 ends in 616, and 1e20 is exactly 10^20, so the comparison is True.
More Python Programming questions
- What is printed? python calls = [] def f(x): calls.append(x) return x 2 m = map(f, [1, 2, 3]) print(calls) first = next(m) print(calls…
- In Python, when is the outermost iterable of a generator expression such as (x for x in make()) evaluated?
- What is printed? python class Countdown: def init(self, n): self.n = n def iter(self): while self.n > 0: yield self.n self.n -= 2 c =…
- What is printed? python from itertools import permutations p = sorted(permutations('cab')) print([''.join(x) for x in p][3], len(p))
- What is printed? python print(() is (), [] is [], (1, 2) == (1, 2))
- A program must answer 10^5 range-sum queries over an array of 10^5 numbers in CPython. Which approach is fastest?