I encountered the use of // opertor in place of / in a python tutorial I was going through. What is the difference between / and // operator in Python?
Variables with the same value are often stored at separate memory addresses. This means that you should use == and != to compare their values and use the Python is and is not operators only when you want to check whether two variables point to the same memory address.
In Python != is defined as not equal to operator. It returns True if operands on either side are not equal to each other, and returns False if they are equal.
Operator copies a bit to the result if it exists in both operands. (a & b) (means 0000 1100) | Binary OR. It copies a bit if it exists in either operand. (a | b) = 61 (means 0011 1101)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With