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

Course Content

Conditional Statements in Python

Conditional Statements in Python

1. Python if Statement
2. Python if-else Statement
3. Python if-elif-else Statement

book
Challenge: Debugging and Improving Code

Task
test

Swipe to show code editor

The following code tracks a user's heart rate and places them in a heart rate zone (Resting, Fat-Burning, Cardio, or Max). However, there are some issues with the conditions. It uses multiple if statements instead of the more efficient elif structure and has a logical error in how the heart rate ranges are handled. Your task is to debug and improve the code.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 3
toggle bottom row

book
Challenge: Debugging and Improving Code

Task
test

Swipe to show code editor

The following code tracks a user's heart rate and places them in a heart rate zone (Resting, Fat-Burning, Cardio, or Max). However, there are some issues with the conditions. It uses multiple if statements instead of the more efficient elif structure and has a logical error in how the heart rate ranges are handled. Your task is to debug and improve the code.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 3
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt