Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python / vs // operator [duplicate]

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?

like image 800
Ayush Avatar asked Oct 09 '13 05:10

Ayush


People also ask

What is == and != 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.

What does the != operator mean in Python?

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.

What is a B in Python?

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)


1 Answers

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

like image 148
prayagupa Avatar answered Oct 02 '22 09:10

prayagupa