Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Shape Area Calculations | Class Structures
Object Oriented Programming with Python
Sección 1. Capítulo 8
single

single

Challenge: Shape Area Calculations

Desliza para mostrar el menú

Tarea

Desliza para comenzar a programar

Implement the Rectangle class according to the following requirements:

  • Implement the __init__ method to accept and store shape_id, width, and height, using self.

  • To calculate the area(), use following formula:

Area=width×height\text{Area} = \text{width} \times \text{height}
  • Provide an area() instance method that returns a string in the format: "Area: <value> <unit>", with area rounded to 2 decimal places (round()).

  • shape_id is not used in calculations — it is only needed to uniquely identify each shape instance.

  • Do not forget to remove pass in each function.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 8
single

single

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt