Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Implementation | Classes and Objects
Object-Oriented Programming in Python
course content

Contenido del Curso

Object-Oriented Programming in Python

Object-Oriented Programming in Python

1. Classes and Objects
2. Encapsulation
3. Inheritance
4. Polymorphism

Implementation

Code

We start to fill the Cat class:

  • An attribute name with the predefined value 'Kitty';
  • A method say_meow().

We create an object cat and call the say_meow() method.

Note

  • Each method obligatory contains self - a reference to the current object;
  • To call the method of the object, write Object.Method().

Tarea

  1. Add the sleep method.
  2. The sleep method prints a message.
  3. Instantiate an object using the cat variable.

Tarea

  1. Add the sleep method.
  2. The sleep method prints a message.
  3. Instantiate an object using the cat variable.

¿Todo estuvo claro?

Sección 1. Capítulo 3
toggle bottom row

Implementation

Code

We start to fill the Cat class:

  • An attribute name with the predefined value 'Kitty';
  • A method say_meow().

We create an object cat and call the say_meow() method.

Note

  • Each method obligatory contains self - a reference to the current object;
  • To call the method of the object, write Object.Method().

Tarea

  1. Add the sleep method.
  2. The sleep method prints a message.
  3. Instantiate an object using the cat variable.

Tarea

  1. Add the sleep method.
  2. The sleep method prints a message.
  3. Instantiate an object using the cat variable.

¿Todo estuvo claro?

Sección 1. Capítulo 3
toggle bottom row

Implementation

Code

We start to fill the Cat class:

  • An attribute name with the predefined value 'Kitty';
  • A method say_meow().

We create an object cat and call the say_meow() method.

Note

  • Each method obligatory contains self - a reference to the current object;
  • To call the method of the object, write Object.Method().

Tarea

  1. Add the sleep method.
  2. The sleep method prints a message.
  3. Instantiate an object using the cat variable.

Tarea

  1. Add the sleep method.
  2. The sleep method prints a message.
  3. Instantiate an object using the cat variable.

¿Todo estuvo claro?

Code

We start to fill the Cat class:

  • An attribute name with the predefined value 'Kitty';
  • A method say_meow().

We create an object cat and call the say_meow() method.

Note

  • Each method obligatory contains self - a reference to the current object;
  • To call the method of the object, write Object.Method().

Tarea

  1. Add the sleep method.
  2. The sleep method prints a message.
  3. Instantiate an object using the cat variable.

Sección 1. Capítulo 3
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt