Integer Division Operator //
Unlike the /
operator, which returns a floating-point result, the integer division operator //
discards the decimal part and returns only the integer portion of the division.
For example, dividing 10 by 3 using the /
operator yields a result of 3.3333333333333335
.
/ Operator Example
result_float = 10 / 3
print(result_float) # 3.3333333333333335
In contrast, dividing 10 by 3 using the //
operator results in the integer 3
.
// Operator Example
result_int = 10 // 3
print(result_int) # 3
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.