Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Debugging and Improving Code Logic | Mastering Python if-elif-else Statements
Conditional Statements in Python
course content

Kurssisisältö

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: Debugging and Improving Code Logic

Tehtävä

Swipe to start coding

Your task is to debug and improve the heart rate tracking system to ensure it efficiently assigns users to the correct heart rate zone.

  • Use an if-elif-else structure instead of multiple if statements for better efficiency and readability.
  • Ensure the logic correctly categorizes heart rate values and avoids redundant conditions.
  • Assign the correct heart rate zone based on the given heart rate.
  • Max Zone if the heart rate is 150 or above.
  • Cardio Zone if the heart rate is between 100 and 149, inclusive.
  • Fat-Burning Zone if the heart rate is between 60 and 99, inclusive.
  • Resting Zone if the heart rate is below 60.
  • Store the assigned zone in the zone variable.
  • Ensure all if, elif, and else statements end with a colon (:).

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 3
toggle bottom row

book
Challenge: Debugging and Improving Code Logic

Tehtävä

Swipe to start coding

Your task is to debug and improve the heart rate tracking system to ensure it efficiently assigns users to the correct heart rate zone.

  • Use an if-elif-else structure instead of multiple if statements for better efficiency and readability.
  • Ensure the logic correctly categorizes heart rate values and avoids redundant conditions.
  • Assign the correct heart rate zone based on the given heart rate.
  • Max Zone if the heart rate is 150 or above.
  • Cardio Zone if the heart rate is between 100 and 149, inclusive.
  • Fat-Burning Zone if the heart rate is between 60 and 99, inclusive.
  • Resting Zone if the heart rate is below 60.
  • Store the assigned zone in the zone variable.
  • Ensure all if, elif, and else statements end with a colon (:).

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 3
Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt