ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(sum([1, 2, 3]) / 2 // 1, 7 // 2 / 2, divmod(7.0, 2)[0] == 7 // 2)
- A. 3 1.5 True
- B. 3.0 1.5 False
- C. 3.0 3.5 True
- D. 3.0 1.5 True
Correct answer: D. 3.0 1.5 True
6 / 2 is 3.0, and floor division by 1 keeps it a float. 7 // 2 / 2 is 3 / 2 = 1.5, and divmod of a float gives a float quotient equal to 3.0.
More Python Programming questions
- What is printed? python print('{:^6}'.format('ab'), '{:<4}'.format(1), '{:>3}|{:<3}|'.format('a', 'b'))
- What is printed? python print('a' < 'b' < 'c', 'b' > 'a' and 'b' > 'c')
- What is printed? python print(len([range(3), 'ab']), ['ab', [1]], {{'a': 1}, 'a': 2})
- What is printed? python print(hash(()) == hash(()), (1, 2) < (1, 2, 0), 'b' 2 > 'ab' 2, (1, 'b') < (1, 'a'))
- What is printed? python print(sorted(['b', 'B', 'a'], key=lambda s: (s.lower(), s)))
- What is printed? python from math import prod print(prod([2, 3, 4]), prod([]), prod([0.5, 4]), prod(range(1, 4), start=10))