Search code examples
python-3.xoperators

Python operators '/' vs. '//'


I encountered the use of the // operator in place of / in a Python tutorial I was going through. What is the difference between the / and // operator in Python?


Solution

  • In Python 3.0 and above, check in your terminal.

    a) / operator, aka classic division

    >>> 5/2
    2.5
    

    b) // operator, aka floor division

    >>> 5//2
    2
    

    Reference

    9.9. operator — Standard operators as functions