Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: The Digital Tea Kettle | Asynchronous Programming (asyncio)
Python Structural Programming
Sektion 4. Kapitel 3
single

single

Challenge: The Digital Tea Kettle

Stryg for at vise menuen

Opgave

Swipe to start coding

Create a coroutine that simulates a digital tea kettle boiling water.

  • Define a coroutine function called boil_water using the async keyword.
  • Inside the coroutine, print "Kettle is on...".
  • Simulate boiling for 3 seconds.
  • After the wait, print "Ding! Water is boiled.".

Your code should produce: Kettle is on... waits for 2 seconds Ding! Water is boiled.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 3
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt