Last active
December 27, 2015 00:19
-
-
Save austa/7237279 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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