ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(any(x > 3 for x in range(10)), next(x for x in range(10) if x * x > 20), sum(x for x in range(0, 10, 4)))
- A. True 5 15
- B. False 5 12
- C. True 5 12
- D. True 4 12
Correct answer: C. True 5 12
any stops at the first x greater than 3, so it is True. The first x with x*x > 20 is 5, since 4*4 = 16 and 5*5 = 25. range(0, 10, 4) gives 0, 4 and 8, which sum to 12.
More Python Programming questions
- What is printed? python s = '12:34:56' h, m, sec = map(int, s.split(':')) print(h 3600 + m 60 + sec, divmod(h 3600 + m 60 + sec, 60))
- What is printed? python print([x % 3 for x in [-7, -3, 0, 4]])
- What is printed? python def counter(): count = 0 def step(): nonlocal count count += 2 return count return step c1 = counter() c2 =…
- What is printed? python values = {'x': [1, 2], 'y': [3]} total = sum(len(v) for v in values.values()) keys = sorted(values, key=lambda k…
- What is printed? python print(int(' -0012 '), int('+5'), float('-.5'), float('5.'))
- What is printed? python x = 10 y = x y += 1 z = [x] z[0] += 5 print(x, y, z)