ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(10 ** -2, 10.0 ** -2, 1_000 * 1_0, 2 ** -1 * 4)
- A. 0.01 0.01 10000 0.5
- B. 0.01 0.01 10000 2.0
- C. 0.01 0.01 10000 2
- D. 0.01 0.01 1000 2.0
Correct answer: B. 0.01 0.01 10000 2.0
A negative int exponent on an int base gives a float, so 10 ** -2 is 0.01. 2 ** -1 is 0.5, and multiplying by 4 gives 2.0 as a float, not the int 2.
More Python Programming questions
- What is printed? python print(bool(0.0), bool(-0.0), bool(float('nan')), bool(' '), bool('0'), bool(0j))
- What is printed? python s1 = 'u00e9' s2 = 'eu0301' print(s1 == s2, len(s1), len(s2), len(s2.encode()), s2 == 'eu0301')
- What is printed? python print(len('héllo'.encode('utf-8')), len('héllo'.encode('utf-16')), len('héllo'))
- What is printed? python print('abc' < 'abd', 'Z' < 'a', '10' < '9', [10] < [9], (1, 'b') < (1, 'a'))
- What is printed on the second line? python print(''.join(sorted('banana'))) print(sorted('Banana', key=str.lower)) print(sorted(['b10'…
- What is printed? python print(min([3, 1.0, True]), max([1, True, 1.0]), max([True, 1.0]), min([1.0, True]))