ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(7.0 == 7, (7.0).is_integer(), (7.5).is_integer(), 1e3 == 1000)
- A. True False False True
- B. True True True True
- C. True True False True
- D. True True False False
Correct answer: C. True True False True
Float and int compare by value, so 7.0 == 7 and 1e3 == 1000 are True. is_integer() is True only when the float has no fractional part, which is true for 7.0 but not 7.5.
More Python Programming questions
- What is printed? python print(2 0.5 2 0.5 == 2, (2 0.5) 2, 2 0.5 2)
- What is printed? python print('%.2f' % 1.005, '%.2f' % 1.015, '%.2f' % 1.025, '%.1f' % 0.25)
- What is printed? python s = 'abc' t = s s += 'd' print(t, s, t is s, id(s) == id(t))
- What is printed? python def tosigned(v): return v - (1 << 32) if v >= 1 << 31 else v print(tosigned(0xFFFFFFFE), tosigned(0x7FFFFFFF)…
- What is printed? python s = 'hello world' print(s.capitalize(), s.title().swapcase(), s.center(15, ''), s.zfill(13))
- What is printed? python print(divmod(-7, 2), divmod(7, -2.0), 7 // -2.0, -7 % 2.5)