Created
January 5, 2011 16:07
-
-
Save fajran/766508 to your computer and use it in GitHub Desktop.
This file contains 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
class Angka(object): | |
def __init__(self, nilai): | |
self.nilai = nilai | |
def berapa(self): | |
return self.nilai | |
satu = Angka(1) | |
print satu.berapa() | |
dua = Angka(2) | |
print dua.berapa() | |
print Angka.berapa(satu) | |
print Angka.berapa(dua) |
This file contains 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
class Kalkulator(object): | |
def tambah(self, a, b): | |
return a + b | |
def kali(self, a, b): | |
jumlah = 0 | |
for i in range(b): | |
jumlah = self.tambah(jumlah, a) | |
return jumlah | |
k = Kalkulator() | |
print k.tambah(1, 2) | |
print k.kali(2, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment