ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(len(str(10**50 + 1).rstrip('0')), str(10**50 + 1)[-2:], str(10**50 - 1)[:3])- A. 50 01 999
- B. 51 10 999
- C. 51 01 999
- D. 51 01 100
Correct answer: C. 51 01 999
10**50 + 1 ends in 1, so rstrip removes nothing and the length stays 51. Its last two digits are 01, and 10**50 - 1 is all nines starting with 999.
More Python Programming questions
- What is printed? python print(max(map(len, ['abc', 'de', 'fghi'])), list(map(len, ['abc', '', 'x'])), sum(map(len, ['ab', 'cd'])))
- What is printed? python print(float('1e-3') 1000 == 1, int(float('1e-3') 1000), round(float('1e-3') 1000))
- 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))