Course Content
Conditional Statements in Python
Conditional Statements in Python
Challenge: Debugging and Improving Code
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
Thanks for your feedback!
Challenge: Debugging and Improving Code
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
Thanks for your feedback!