ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(7 / 2 // 1, 7 // 2 / 1, -7 / 2 // 1, 7 % 2.5)
- A. 3.0 3.0 -3.0 2.0
- B. 3 3.0 -4.0 2.0
- C. 3.0 3.0 -4.0 2.0
- D. 3.0 3.5 -4.0 2.0
Correct answer: C. 3.0 3.0 -4.0 2.0
7 / 2 is 3.5 and floor division by 1 gives 3.0. -7 / 2 is -3.5, which floors to -4.0. 7 % 2.5 is 2.0.
More Python Programming questions
- What is printed? python print('abc'.find(''), 'abc'.count(''), ''.split(), ''.split(','))
- What is printed? python from fractions import Fraction print(Fraction(1, 3) == 1/3, Fraction(1, 3) == Fraction('0.3333333333333333')…
- What is printed? python print('Hello, World'.swapcase(), 'hello world'.title(), "it's here".capitalize(), 'ABC'.isupper())
- What is printed? python print(float('9007199254740993') == 9007199254740993, int(float('9007199254740993')), int(9007199254740993.0))
- What is printed? python print(len('abc' 1000000 + ''), 'abc' in 'x' 10 + 'abc', 'ab' < 'abc', [1, 2] < [1, 2, 0])
- What is printed? python print(10 -1 == 0.1, 10 0.5 == 10 (1 / 2), int(10 0.5) 2 == 10, round(10 0.5 10 0.5, 9))