Skip to content

Instantly share code, notes, and snippets.

@austa
Last active December 27, 2015 00:19
Show Gist options
  • Save austa/7237279 to your computer and use it in GitHub Desktop.
Save austa/7237279 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
#Taban donusturme
class Stack:
def __init__(self):
self.liste = []
def isEmpty(self):
return self.liste == []
def push(self, eklenen):
self.liste.append(eklenen)
def pop(self):
return self.liste.pop()
def size(self):
return len(self.liste)
def tabanDonustur(sayi, taban):
degerler = "0123456789ABCDEF"
s = Stack()
while sayi > 0:
kalan = sayi % taban
s.push(kalan)
sayi = sayi / taban
yeniString = ""
while not s.isEmpty():
yeniString = yeniString + degerler[s.pop()]
return yeniString
print tabanDonustur(26, 16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment