Sectie 1. Hoofdstuk 8
single
Challenge: Shape Area Calculations
Veeg om het menu te tonen
Taak
Veeg om te beginnen met coderen
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.
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 1. Hoofdstuk 8
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.