ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(int(2.5 * 4) // 3, int(10 / 4 * 2), 10 // 4 * 2, 10 / 4 // 2)
- A. 3 5 4 2.0
- B. 3 4 4 1.0
- C. 3 5 5 1.0
- D. 3 5 4 1.0
Correct answer: D. 3 5 4 1.0
2.5 * 4 is exactly 10.0, so int gives 10 and 10 // 3 is 3. 10 / 4 is 2.5, and 2.5 // 2 floors 1.25 to 1.0, which is why the last value is a float 1.0.
More Python Programming questions
- What is printed? python print(float(1) / 3 + float(2) / 3 == 1.0, 0.1 0.1 100 == 1.0, 1 - 0.1 9 == 0.1)
- What is printed? python print(f"{0.1:.20f}")
- What is printed? python def nge(a): st, res = [], [-1] len(a) for i, x in enumerate(a): while st and a[st[-1]] < x: res[st.pop()] = x…
- What is printed? python from itertools import takewhile, dropwhile a = [1, 3, 4, 6, 7, 9] print(list(takewhile(lambda x: x % 2, a))…
- What is printed? python def f(): try: return 'try' finally: print('finally', end=' ') print(f())
- What is printed? python def g(): try: return 1 finally: return 2 print(g())