ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(str(1e-5), 0.0001, 0.00001, 1e-4 == 0.0001, 10 ** -4)
- A. 0.00001 0.0001 0.00001 True 0.0001
- B. 1e-05 0.0001 1e-05 False 0.0001
- C. 1e-05 0.001 1e-05 True 0.0001
- D. 1e-05 0.0001 1e-05 True 0.0001
Correct answer: D. 1e-05 0.0001 1e-05 True 0.0001
Floats smaller than 1e-4 print in exponent form with at least two exponent digits, so 0.00001 shows as 1e-05. 0.0001 is printed in full, and 10 ** -4 is the same float as the literal.
More Python Programming questions
- What is printed? python print(sorted(['10', '9', '2b', '2a']), sorted([10, 9, 2], key=str))
- What is printed on the last line? python try: sorted([1, '2']) except TypeError: print('TypeError') print(sorted([1, '2'], key=str))
- What is printed? python print(max([], default=-1), min([3], default=0), sum([]), sum([], 0.0), any([]) or all([]))
- What is printed on the first line? python words = ['apple', 'Bob', 'cat', 'Dog', 'ant'] print(sorted(words, key=lambda w: (w[0].lower()…
- What is printed on the second line? python nums = [5, -3, 0, 2, -3] print(sorted(nums, key=lambda x: x < 0)) print(sorted(nums, key=lambda…
- What is printed on the first line? python data = [('x', 3.0), ('y', 3), ('z', 2.5)] print(sorted(data, key=lambda t: t[1]))…