Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Creating and Using Methods | Johdanto Pythonin Olio-Ohjelmointiin
Olio-ohjelmointi Pythonissa

bookChallenge: 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 takes width and height as arguments and stores them as instance variables.
  • Implement a method called area that returns the area of the rectangle.
  • Implement a method called perimeter that returns the perimeter of the rectangle.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 5
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookChallenge: 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 takes width and height as arguments and stores them as instance variables.
  • Implement a method called area that returns the area of the rectangle.
  • Implement a method called perimeter that returns the perimeter of the rectangle.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 5
single

single

some-alt