ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(round(3.14159, 3), round(2.5e-7, 7), round(123.456, -1), round(-0.0001, 2))
- A. 3.142 2e-07 120.0 -0.0
- B. 3.142 3e-07 120.0 -0.0
- C. 3.142 2e-07 130.0 -0.0
- D. 3.141 2e-07 120.0 -0.0
Correct answer: A. 3.142 2e-07 120.0 -0.0
2.5e-7 is stored a little below the half-way mark, so it rounds down to 2e-07. Rounding a small negative float to two places keeps the sign, so the result is -0.0.
More Python Programming questions
- What is printed? python print('Hello World'.swapcase().title(), 'tEST'.capitalize(), 'x'.isalpha(), '1.5'.isdigit(), '١٢'.isdigit())
- What is printed? python print('ab' in 'cabd', '' in 'abc', 'abc'.index(''), len('abc'[3:]), len('abc'[4:]))
- What is printed? python print(sum(map(int, str(220))), len(str(350)), str(105)[::-1].count('0'))
- What is printed? python print(float('0.1') + float('0.2') == float('0.30000000000000004'), 0.1 + 0.2 == 0.30000000000000004)
- What is printed? python print(5 // 0.4, 5 % 0.4, 0.4 12 == 4.8, 5 / 0.4)
- What is the time complexity of s[::-1] for a string of length n in CPython?