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
2.5
>>> 5 // 2
2
2
>>>
👍
ReplyDeleteThanks : )
DeleteHello! I think 5//2 is 2 not 4
ReplyDeleteSorry, I have corrected it.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )