Python casting int("string", integer) -
what logic behind
int("string", integer)
for example:
int("220", 3)
yields
24
the optional integer numeric base use in converting string (defaults base 10).
220 base 3 = 2 * (3**2) + 2 * (3**1) + 0 * (3**0) = 2*9 + 2*3 + 0*1 = 18 + 6 + 0 = 24
Comments
Post a Comment