Division Operators in Python

07 Jun, 2022
Division Operators allow you to divide two numbers and return a quotient, i.e., the first number or number at the left is divided by the second number or number at the right and returns the quotient. 
There are two types of division operators: 
The quotient returns by this operator is always a float number, no matter if two numbers are integer. For example:
>>>5/5
1.0
>>>10/2
5.0
>>>-10/2
-5.0
>>>20.0/2
10.0
The quotient returned by this operator is dependent on the argument being passed. If any of the numbers is float, it returns output in float. It is also known as Floor division because, if any number is negative, then the output will be floored. For example:
>>>5//5
1
>>>3//2
1
>>>10//3
3
Consider the below statements in Python.
Python3
# A Python program to demonstrate the use of# "//" for integersprint (5//2)print (-5//2)
Output:
2
-3
The first output is fine, but the second one may be surprised if we are coming Java/C++ world. In Python, the “//” operator works as a floor division for integer and float arguments. However, the division operator ‘/’ returns always a float value.
Note: The “//” operator is used to return the closest integer value which is less than or equal to a specified expression or value. So from the above code, 5//2 returns 2. You know that 5/2 is 2.5, and the closest integer which is less than or equal is 2[5//2].( it is inverse to the normal maths, in normal maths the value is 3).
Example
Python3
# A Python program to demonstrate use of# "/" for floating point numbersprint (5.0/2)print (-5.0/2)
2.5
-2.5

The real floor division operator is “//”. It returns the floor value for both integer and floating-point arguments.
Python3
# A Python program to demonstrate use of# "//" for both integers and floating pointsprint (5//2)print (-5//2)print (5.0//2)print (-5.0//2)
2
-3
2.0
-3.0

See this for example. 
Python Programming Tutorial - Operators - Part 1 | GeeksforGeeks - YouTubeGeeksforGeeks529K subscribersPython Programming Tutorial - Operators - Part 1 | GeeksforGeeksWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:000:00 / 3:38•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=oiJUZbRIR7Y" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
f20180508
vicky2321984
sheetal18june
Python
School Programming
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Different ways to create Pandas Dataframe
Reverse a string in Java
Arrays in C/C++
Interfaces in Java
Inheritance in C++
Object Oriented Programming in C++