Social Widget

Responsive Ads Here

Monday, January 20, 2020

difference between '/' and '//' in python

Python Operators

Operators are used to perform operations on variables and values. Python divides the operators in the following groups:

1. Arithmetic operators
2. Assignment operators 
3. Comparison operators 
4. Logical operators 
5. Identity operators 
6. Membership operators 
7. Bitwise operators

Difference between '/' and '//' in python

/ is regular division(returns float) and // is floor division(returns int).

Floor division was introduced in python 3.


Normal Division : Divides the value on the left by the one on the right. Notice that division results in a floating-point value.

Floor Division : Divides and returns the integer value of the quotient. It neglects the digits after the decimal.


Output is: 

    Value of a is 3.3333333333333335    Value of b is 3

No comments:

Post a Comment