Challenge: Creating and Using Methods
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 1. Luku 5
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Mahtavaa!
Completion arvosana parantunut arvoon 3.85
Challenge: Creating and Using Methods
Pyyhkäise näyttääksesi valikon
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 1. Luku 5
single