ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(sum(x * x for x in range(-3, 4)), sum(abs(x) for x in range(-3, 4)))
- A. 28 12
- B. 28 0
- C. 12 28
- D. 28 6
Correct answer: A. 28 12
The squares of -3 to 3 are 9, 4, 1, 0, 1, 4, 9, which sum to 28. The absolute values sum to 3 + 2 + 1 + 0 + 1 + 2 + 3 = 12.
More Python Programming questions
- What is printed? python print(2 0.5 2 0.5 == 2, round(2 0.5 2 0.5, 12) == 2)
- What is printed? python print(''.join(reversed('ab' 2)), 'ab'[::-1] 2 == 'baba')
- Which operation is O(1) on average in CPython?
- A loop runs s += c for 100000 single characters in CPython. Which statement is most accurate?
- Which statement about converting a string to an int in Python 3.13 is correct?
- What relative and absolute tolerances does math.isclose use by default?