Weekday or Weekend
Take a weekday number (1-7) and determine if it is a weekday or weekend.
IntermediatePhase 1 - Level 4: Logical Operators & Compound StatementsExample 8 of 10
weekday-or-weekend.py
1# Take day number2day = int(input("Enter day number (1-7): "))34# Check weekday or weekend5if 1 <= day <= 5:6 print("Weekday")7elif day == 6 or day == 7:8 print("Weekend")9else:10 print("Invalid day")
Output
Enter day number (1-7): 3 Weekday Enter day number (1-7): 6 Weekend
What's going on
Classify days into weekday and weekend.
Key Concepts:
Weekday: 1-5 (Mon-Fri)
Weekend: 6-7 (Sat-Sun)
Use range check and OR
🔗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