ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(float('1e-3') * 1000 == 1, int(float('1e-3') * 1000), round(float('1e-3') * 1000))- A. True 1 1
- B. False 0 1
- C. True 0 1
- D. True 1 0
Correct answer: A. True 1 1
1e-3 * 1000 happens to round to exactly 1.0 here, so the equality holds and int and round both give 1. Other numbers can land just under an integer, which is why int can differ from round.
More Python Programming questions
- What is printed? python print(len({'a': 1, 'b': 2}), len({'a', 'a', 'b'}), len(dict.fromkeys('hello')))
- What is printed? python print(sorted({'b': 2, 'a': 3}.items(), key=lambda kv: kv[1])[0][0], list({'b': 2, 'a': 3})[-1])
- What is printed? python print(3 3 0, (3 3) 0, 0 3 0, (0 3) 0)
- What is printed? python import math print(math.isclose(0.1 + 0.2, 0.3), math.isclose(0.0, 1e-10), math.isclose(0.0, 1e-10, abstol=1e-9))
- What is printed? python print(int(9.99), int(-9.99), round(9.99), round(-9.99), 0)
- What is printed? python def span(p): st, out = [], [] for i, x in enumerate(p): while st and p[st[-1]] <= x: st.pop() out.append(i…