ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(sum(range(10)) / len(range(10)), sum(range(10)) // len(range(10)), sum(range(1, 11)) % 7)
- A. 4.5 4 3
- B. 4.5 4 6
- C. 4.0 4 6
- D. 4.5 5 6
Correct answer: B. 4.5 4 6
The sum of 0 to 9 is 45, and dividing by 10 gives 4.5 with / and 4 with //. The sum of 1 to 10 is 55, and 55 mod 7 is 6.
More Python Programming questions
- What is printed? python n = 12345 print(n // 10 3 % 10, n % 10 3 // 100, str(n)[1], n // 1000 % 10 == int(str(n)[1]))
- What is printed? python import math print(math.gcd(240 - 1, 220 - 1) == 220 - 1, math.lcm(12, 18) == 36, math.gcd(1030, 1020) == 1020)
- What is printed? python s = 'racecar level noon python' print([w for w in s.split() if w == w[::-1]], len([w for w in s.split() if w ==…
- What is printed? python s = 'aAbBcC' print(s.lower().count('a') + s.upper().count('A'), s.swapcase(), ''.join(c for c in s if c.islower()))
- What is printed? python s = '2024-06-01' y, m, d = map(int, s.split('-')) print(y + m + d, s.replace('-', '/'), '%02d/%02d/%04d' % (d, m…
- What is printed? python print('%d' % 1020, '%.3e' % (270), len('%d' % (2100)), '%x' % (270))