Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.


+6 votes

What is the difference between / and //?

I know both produce float numbers

asked in CSC201 Spring 2021 by (664 points)

5 Answers

+2 votes

/ will produce floating division
Ex: 27/8 = 3.375
// will produce integer division
Ex: 27/8 = 3

Hope this helps!

answered by (1.9k points)

ahh!! thank you~!!!!

+2 votes

/ is used for regular division, and produces float numbers.

// is used for integer division, and only produces integers, dropping any remainder.

for example, 9//2 = 4 , since 2 goes into 9 4 whole times.

answered by (1.5k points)

thanks so much!!!

+2 votes

/ is for regular division and // is used to indicate integer division. 10/3=3.33 but 10//3=3 because 3 goes into 10 three times.

answered by (1.2k points)
+2 votes

You use / when you want division that answer only keeps the whole integer and drop the remainder

You use / when you want division that answer will be a float, which comes out to be a decimal number, ...

answered by (1.2k points)
+1 vote

/ is used as a regular division and it produces floating numbers. For example- 22/3 = 7.33

// is used as a integer division and produces integers and real numbers, leaving out the remainders.
For example- 24/5 = 4 (5*4=20)

answered ago by (1.1k points)