On Aug 12, 2007, at 11:34 AM, Ed Leafe wrote:
> # floor division yields no decimals and no rounding
> givetocustomer[pos] = change // denom
> # modulus returns remainder
> change = change % denom
Oh, yeah - here's another built-in Python goodie: the divmod()
function:
print divmod(25, 3)
-> (8, 1)
print divmod(10, 7)
-> (1, 3)
print divmod(33, 3)
-> (11, 0)
So the lines above can be written as:
givetocustomer[pos], change = divmod(change, denom)
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]