tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1 @@
|
|||
i = int('1a',16) # returns the integer 26
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
digits = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
def baseN(num,b):
|
||||
return (((num == 0) and "0" )
|
||||
or ( baseN(num // b, b).lstrip("0")
|
||||
+ digits[num % b]))
|
||||
|
||||
# alternatively:
|
||||
def baseN(num,b):
|
||||
if num == 0: return "0"
|
||||
result = ""
|
||||
while num != 0:
|
||||
num, d = divmod(num, b)
|
||||
result += digits[d]
|
||||
return result[::-1] # reverse
|
||||
|
||||
k = 26
|
||||
s = baseN(k,16) # returns the string 1a
|
||||
Loading…
Add table
Add a link
Reference in a new issue