0
how does the built-in function: int(s, base) works?
I was going thru the use of this function but want alter to figure out how it works... for e.g. int("A9",13) will give the result: 139 and, int("B7", 17) will give .. 194 so, could some one pls. explain how come this actually happened.. Many Thanks, Adarsh :)
3 Antworten
+ 3
This function has two arguments. The first argument is how the number is displayed, the second one: the base the number is written in. From examples given in question: A9 in base 13 is 139 and B7 in base 17 is 194. I hope I helped.
+ 2
One more thing. Attemting to put ciphers from wrong base eg 9 in base 8 raises ValueError.
+ 1
yeah that helped and I also got some help from an online converter.
That would be a tedious task to calculate manually... thanks to Python.
have a great time ahead.
Regards,
Adarsh