ProgrammingHardTCS NQT · Wipro pattern

What is printed?

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

Correct answer: D. float int float int

/ always gives a float and // keeps an int. A negative integer exponent gives a float, while a non-negative one stays an int.

More Python Programming questions

Exams that ask this topic