From d2b27792b4ca294c42b90a8f4da0f812e9c9b74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Sun, 13 Nov 2022 08:58:29 -0300 Subject: [PATCH] =?UTF-8?q?M=C3=A9todos=20em=20inst=C3=A2ncias=20de=20clas?= =?UTF-8?q?ses=20Python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aula0121.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 aula0121.py diff --git a/aula0121.py b/aula0121.py new file mode 100644 index 0000000..7e7a370 --- /dev/null +++ b/aula0121.py @@ -0,0 +1,20 @@ +# Métodos em instâncias de classes Python +# Hard coded - É algo que foi escrito diretamente no código +class Carro: + def __init__(self, nome): + self.nome = nome + + def acelerar(self): + print(f'{self.nome} está acelerando...') + + +string = 'Luiz' +print(string.upper()) + +fusca = Carro('Fusca') +print(fusca.nome) +fusca.acelerar() + +celta = Carro(nome='Celta') +print(celta.nome) +celta.acelerar()