ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(type(1 / 2).__name__, type(1 // 2).__name__, type(2 ** -1).__name__, type(2 ** 0.5).__name__, type(True + 1).__name__)
  1. A. float int float float int
  2. B. int int float float int
  3. C. float int int float int
  4. D. float int float int int

Correct answer: A. float int float float int

/ always gives a float and // on ints gives an int. A negative int exponent gives a float, a fractional exponent gives a float, and bool plus int is an int.

More Python Programming questions

Exams that ask this topic