I just want to know how can we use divmod() function for some practical application other than just calculating / and %. I want to know if yes, then how can we use divmod function to prove if a number is prime or not. This would be a perfect practical application of divmod()
Practical Application of divmod() function in python, or how can we use divmod() other than just calculating / and %?
494 Views Asked by Chanandlerbong At
2
One application (don't know whether it is "practical" enough) is to determine the digits comprising an integer:
Output:
Here the quotient is assigned back to
n
effectively stripping off the last digit which is available in the remainder,r
.