ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(round(12345, -2), round(12350, -2), round(12250, -2), round(-1234.5, -1))
- A. 12300 12400 12300 -1230.0
- B. 12300 12400 12200 -1230.0
- C. 12300 12300 12200 -1230.0
- D. 12300 12400 12200 -1230
Correct answer: B. 12300 12400 12200 -1230.0
With a negative ndigits, round works on the tens or hundreds place and still uses half-to-even, so 12350 goes to 12400 and 12250 goes to 12200. Rounding a float keeps the result a float.
More Python Programming questions
- What is printed? python print(format(1234.5678, '.2f'), format(1234.5678, '.2e'), format(0.000012345, '.3g'), format(12345.6789, ',.1f'))
- What is printed? python print(str(1.0), str(1e2), str(1.5e-7), str(123456789012345678.0), str(0.1 + 0.7))
- What is printed? python print(1 / 3 3 == 1.0, 2 / 3 3 == 2.0, 10 / 3 3 == 10.0, 0.7 3 == 2.1)
- What is printed? python print(float('nan') < 1, float('nan') > 1, float('nan') != float('nan'))
- What is printed? python import math print(math.isnan(float('nan') 0), math.isinf(1e308 10), math.isfinite(-0.0), math.copysign(1, -0.0))
- What is printed on the first line? python print(min(0.0, -0.0), max(-0.0, 0.0), min(-0.0, 0.0), -0.0 < 0.0)