ProgrammingHardGATE CS · Product-company placement
What is printed?
What is printed?
print(round(0.125, 2), round(2.675, 2), round(-1.5), round(25, -1), round(35, -1))
- A. 0.12 2.67 -2 20 40
- B. 0.13 2.68 -2 30 40
- C. 0.12 2.68 -1 20 40
- D. 0.13 2.67 -2 30 40
Correct answer: A. 0.12 2.67 -2 20 40
round uses round-half-to-even on the exact binary value: 0.125 is exact and ties to 0.12; 2.675 is really 2.67499..., so 2.67; -1.5 ties to -2; 25 ties to 20 and 35 to 40.
More Python Programming questions
- What is printed? python print(int("٤٢"), "²".isdigit(), "²".isdecimal(), "½".isnumeric(), "4.2".isdigit())
- What is printed? python a = 10 16 print(float(a + 1) == float(a), int(float(2 53 + 1)) - 2 53, 2 53 + 1.0 == 2 53)
- What is printed? python print(divmod(-17, 5), divmod(17, -5), -17 % -5, pow(3, -1, 7))
- What is printed? python print(not 1 == 2, not (1 == 2) is True, (not 1) == 2, 1 + True + True)
- What is printed? python x = 5 print(1 < x < 10 > 3 != 4, 3 > 2 > 1 == True, (3 > 2) > (1 == True), 0 == 0 in [0])
- What is printed? python s = "a,b,,c," print(len(s.split(",")), len(s.split()), s.rsplit(",", 2)[0], s.partition(";")[0] == s)