Temperature Range Check
Take a temperature value and print "Cold", "Warm", or "Hot" using range conditions.
BeginnerPhase 1 - Level 1: Simple ConditionsExample 8 of 10
temperature-range-check.py
1# Take temperature as input2temp = float(input("Enter temperature: "))34# Classify temperature5if temp < 20:6 print("Cold")7elif temp < 30:8 print("Warm")9else:10 print("Hot")
Output
Enter temperature: 15 Cold Enter temperature: 25 Warm Enter temperature: 35 Hot
What's going on
Use range conditions to classify temperature.
Key Concepts:
Check ranges using < and >=
< 20: Cold
20 to 29: Warm
>= 30: Hot
Order matters: check smaller ranges first
🔗Related Content
- 📖
Phase 1 - Learn Concepts
Review Phase 1 concepts and explanations
- 📝
Phase 1 - Quiz
Test your Phase 1 understanding with quiz questions
- 💻
Phase 1 - All Practice Problems
Explore all practice problems for Phase 1
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum