Double slash

Python double slash

As we know that python works on two-division operators which are single slash and double slash. Similarly, python supports two kinds of divisions which are floating-point division and integer division. If the user wishes that the output should be in decimal values, he makes the use of a single slash which is denoted by β€˜/’. However, if the user wishes to have an answer as the floor value or integer, he can use a double slash denoted by β€˜//’.

For example:
8/3: 2.666 
8//3: 2

Python program to use double slash


The output of this python program will be:


In the above program, we are calculating the floor value with the help of a division operator called double slash. Floor of a digit is the value which is nearest, majorly small than the actual value.  

As in the program, 3//4 is 1 and when we calculate its floor value, it will be 0. Python 2 supports single slash division operator however we get to work with double slash since the launch of python 3. The user can simply use β€˜/’ if he wants the value in floating number or the quotient of the floating number. Otherwise, he can use β€˜//’ to get the returned value as an integer value. In the β€˜//’ case, the factorial part will be discarded and the result will be just integer.

Python Double Slash in Path

In python, double slash does not always work for defining paths. Path manipulation is not so easy which working with division operators. Each language has its own set of rules, hence the use of single slash β€˜/’ and double slash β€˜//’ is made differently. So to conclude with the division operators in python, β€˜/’ is known as division operator and β€˜//’ is known as floor division operator.

If you have any query regarding this post, please feel free to comment below.

Leave a comment

Your email address will not be published. Required fields are marked *