Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Creating and Using Methods | Introduction à la POO en Python
Practice
Projects
Quizzes & Challenges
Quiz
Challenges
/
Programmation Orientée Objet en Python

bookChallenge: Creating and Using Methods

Tâche

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.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 5
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

bookChallenge: Creating and Using Methods

Glissez pour afficher le menu

Tâche

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 5
single

single

some-alt