Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Implementing a Workout Duration Tracker with if-elif-else | Mastering Python if-elif-else Statements
Conditional Statements in Python
course content

Kursusindhold

Conditional Statements in Python

Conditional Statements in Python

1. Mastering Python if Statements
2. Mastering Python if-else Statements
3. Mastering Python if-elif-else Statements

book
Challenge: Implementing a Workout Duration Tracker with if-elif-else

Opgave

Swipe to start coding

Your fitness tracker evaluates the user's workout duration and provides feedback accordingly. The program should categorize workout times and display an appropriate message based on the user's exercise duration.

  • Use an if-elif-else structure to ensure the logic is efficient and well-structured.
  • If the user worked out for more than 60 minutes, congratulate them for completing a long session.
  • If the workout lasted between 30 and 60 minutes, including both limits, encourage them to keep up the good work.
  • If the workout was less than 30 minutes, remind them to aim for a longer session next time.
  • Store the feedback message in a variable for later use.
  • Ensure all if, elif, and else statements end with a colon (:).

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 3. Kapitel 2
toggle bottom row

book
Challenge: Implementing a Workout Duration Tracker with if-elif-else

Opgave

Swipe to start coding

Your fitness tracker evaluates the user's workout duration and provides feedback accordingly. The program should categorize workout times and display an appropriate message based on the user's exercise duration.

  • Use an if-elif-else structure to ensure the logic is efficient and well-structured.
  • If the user worked out for more than 60 minutes, congratulate them for completing a long session.
  • If the workout lasted between 30 and 60 minutes, including both limits, encourage them to keep up the good work.
  • If the workout was less than 30 minutes, remind them to aim for a longer session next time.
  • Store the feedback message in a variable for later use.
  • Ensure all if, elif, and else statements end with a colon (:).

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 3. Kapitel 2
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt