ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(10 / 2, 10 // 2, 7 / 7, 2 * 3 + 4)
- A. 5.0 5 1.0 10
- B. 5 5 1 10
- C. 5.0 5 1 10
- D. 5.0 5 1.0 14
Correct answer: A. 5.0 5 1.0 10
/ always returns a float, so 10 / 2 is 5.0 and 7 / 7 is 1.0. // on ints returns an int, and multiplication binds tighter than +, so 2 * 3 + 4 is 10.
More Python Programming questions
- What is printed? python print('abc'.index('c'), 'abcabc'.rfind('b'), 'abc'.find('d'), len('abc'[1:]))
- What is printed? python print(sorted('bca'), ''.join(sorted('bca', reverse=True)), sorted([3, 1, 2], reverse=True)[0], list(reversed('ab')))
- What is printed? python print(int('12') + int('3'), '12' + '3', 12 + 3 == int('15'), 'x')
- What is printed? python s = 'Python' print(s[0], s[-1], s[1:4], s[::2])
- What is printed? python print(len([1, 2, 3] 2), [1, 2] + [3], [0] 0, [[0] 2] 2 == [[0, 0], [0, 0]])
- What is printed? python print('Hello'.lower() == 'hello', 'Hello'.islower(), 'hello'.isalpha(), 'h3llo'.isalnum())