Created
October 25, 2016 13:26
-
-
Save felipessalvatore/a0c368d321c055c0b14d76d57be65b50 to your computer and use it in GitHub Desktop.
Very basic class creation in python
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
class Conta: | |
#Exemplo mais simples de classe" | |
#Como inicialiar o objeto de uma classe" | |
def __init__(self): | |
self.data = [] | |
self.saldo = 2200 | |
self.ano = 2016 | |
self.nome = "Felipe" | |
def f(self,z): | |
return 'Today is the year {}. Hello world'.format(z) | |
class Contacomplex: | |
#Exemplo mais complexo de classe" | |
def __init__(self, saldo,ano,nome): | |
self.saldo = saldo | |
self.ano = ano | |
self.nome = nome | |
def extrato(self): | |
print("{0} , no ano {1}, você tem ${2}".format(self.nome,self.ano,self.saldo)) | |
y = Contacomplex(900,1998,"João") | |
y.extrato() | |
z = Contacomplex(1100,2008,"Fabiano") | |
z.extrato() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment