ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(float('1e2') == 100, int(float('1e2')), str(float('1e2')), int('100'))- A. True 100 100 100
- B. False 100 100.0 100
- C. True 100 100.0 100
- D. True 100 100.0 10
Correct answer: C. True 100 100.0 100
1e2 is the float 100.0, which equals the int 100, and int() of it gives 100. str() of a float keeps the decimal point.
More Python Programming questions
- What is printed? python print(round(1.0000000000000002, 15) == 1, 1.0000000000000002 == 1, 1.0000000000000002 - 1 == 2.220446049250313e-16)
- What is printed? python s = 'hello world' print(s.title().split()[1][::-1], s.rsplit(' ', 1)[0], s.count('o', 5))
- What is printed? python print(int(0.1 10), round(0.1 10, 10) == 1, 0.1 10 == 1)
- What is printed? python print(abs(-0.0), abs(-3), abs(True), abs(-2 63))
- What is printed? python print(bool(0.0 or 0j), bool(0j or 1j), 0j == 0, 1j 1j)
- What is printed? python print([x for x in range(5) if x % 2], [x for x in 'a1b2' if x.isdigit()], {x % 3 for x in range(6)})