Seksjon 1. Kapittel 8
single
Challenge: Shape Area Calculations
Sveip for å vise menyen
Oppgave
Sveip for å begynne å kode
Implement the Rectangle class according to the following requirements:
-
Implement the
__init__method to accept and storeshape_id,width, andheight, usingself. -
To calculate the
area(), use following formula:
-
Provide an
area()instance method that returns a string in the format:"Area: <value> <unit>", with area rounded to 2 decimal places (round()). -
shape_idis not used in calculations — it is only needed to uniquely identify each shape instance. -
Do not forget to remove
passin each function.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 8
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår