Q. How does the // operator differ from the / operator? Give an example of where // would be needed.

 

Answer =

 

The // operator is the division in which only the whole part of the result is given in the output and the fractional part is truncated. While / operator dived the value and give full answer in float value.

// operator would be needed when we want only integer value.

 

Example:-

>>> 5 / 2
2.5

>>> 5 // 2
2

>>> 

4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post