Repaso
Español
PythonCorePY-51

What do 7 / 2 and 7 // 2 return in Python 3?

Options

  1. 3 and 3
  2. 3.5 and 3 (Correct option)
  3. 3.5 and 3.5
  4. 3 and 3.5

Answer

3.5 and 3

Why

/ is normal division and always returns a float (a decimal number): 3.5.

// is floor division: it divides and rounds DOWN to a whole number: 3.

% gives the remainder: 7 % 2 is 1 (useful to check even/odd).

Remember

/ → decimal, // → whole number, % → remainder.

Key terms

Practice this question in Repaso