Challenge: Basic Smores Recipe
Oppgave
Swipe to start coding
When you run this script, it should output the layers of a smore in the correct order: cracker, chocolate, marshmallow, cracker.
This exercise demonstrates the concept of how decorators wrap functionality around a function in Python.
- In the wrapper function of the
crackers
decorator, you need to call the function being decorated (i.e.,func
). This should be done between the two print statements; - Ensure that the function func is called with any arguments and keyword arguments it might receive;
- Similar to the crackers decorator, the chocolate decorator should call the function it's decorating.
- The main task is to put decorators in right sequence. You must receive:
~~cracker~~
-roasted-------marshmallow-
=chocolate=
~~cracker~~
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 5. Kapittel 6
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
Awesome!
Completion rate improved to 3.7
Challenge: Basic Smores Recipe
Sveip for å vise menyen
Oppgave
Swipe to start coding
When you run this script, it should output the layers of a smore in the correct order: cracker, chocolate, marshmallow, cracker.
This exercise demonstrates the concept of how decorators wrap functionality around a function in Python.
- In the wrapper function of the
crackers
decorator, you need to call the function being decorated (i.e.,func
). This should be done between the two print statements; - Ensure that the function func is called with any arguments and keyword arguments it might receive;
- Similar to the crackers decorator, the chocolate decorator should call the function it's decorating.
- The main task is to put decorators in right sequence. You must receive:
~~cracker~~
-roasted-------marshmallow-
=chocolate=
~~cracker~~
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 3.7Seksjon 5. Kapittel 6
single