Challenge: Creating and Using Methods
Tarea
Swipe to start coding
Create a class that represents a rectangle and implements methods to calculate its area and perimeter.
- Define a class named
Rectangle. - Add an
__init__method that takeswidthandheightas arguments and stores them as instance variables. - Implement a method called
areathat returns the area of the rectangle. - Implement a method called
perimeterthat returns the perimeter of the rectangle.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 5
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Genial!
Completion tasa mejorada a 3.85
Challenge: Creating and Using Methods
Desliza para mostrar el menú
Tarea
Swipe to start coding
Create a class that represents a rectangle and implements methods to calculate its area and perimeter.
- Define a class named
Rectangle. - Add an
__init__method that takeswidthandheightas arguments and stores them as instance variables. - Implement a method called
areathat returns the area of the rectangle. - Implement a method called
perimeterthat returns the perimeter of the rectangle.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 5
single