Python 2.7.6 help with modules

Scott W Dunning swdunning at cox.net
Sat Feb 8 19:28:15 EST 2014


On Feb 7, 2014, at 11:29 PM, Chris Angelico <rosuav at gmail.com> wrote
> Close! But if you print out foo and bar, you'll see that you're naming
> them backwards in the second one. The last digit is the remainder
> (modulo), the rest is the quotient.

So, this is more like what you’re talking about?

>>> first = number / 10
>>> second = number % 10
>>> last = first %10
>>> rest = second / 10

I feel stupid saying this and it’s probably because of the variables I’m using but I’m not sure what the above is doing.  For some reason it’s confusing me.  I used the number 55664, so the variable (first) is saying take 55664 and / it by 10, then (second) is saying take the original number divide it by 10 and spit out the remainder?  Then from there (last) is saying take the original number / it by 10 then take that number and divide it by 10 again and give me the remainder?  Then finally (rest) is saying take the remainder of the original number after dividing by ten and divide that number by 10? I guess I’m confused on the result I’m looking for.

I know I’m asking very elementary questions so I really do appreciate not only all of your help but, your patients too!!





More information about the Python-list mailing list