Computer Science
How does the // operator differ from the / operator? Give an example of where // would be needed.
Python Data Handling
29 Likes
Answer
The Division operator (/) divides its first operand by second operand and always returns the result as a float value whereas Floor Division operator (//) divides its first operand by second operand and truncates the fractional part of the result and returns it as an int value. Floor Division operator is useful in situations where we only need the integer part of the division operation result. For example, to determine how many minutes are there in some given number of seconds:
secs = 2565
mins = 2565 // 60
Answered By
14 Likes
Related Questions
In Python, strings are immutable while lists are mutable. What is the difference?
MidAir Airlines will only allow carry-on bags that are no more than 22 inches long, 14 inches wide, and 9 inches deep. Assuming that variables named length, width, and depth have already been assigned values, write an expression combining the three that evaluates to True if bag fits within those limits, and False otherwise.
What are main error types? Which types are most dangerous and why?
A program runs to completion but gives an incorrect result. What type of error would have caused it?