Print Day Name
Take a day number (1-7) and print the corresponding day name.
IntermediatePhase 1 - Level 2: Nested If & Multiple ConditionsExample 9 of 10
print-day-name.py
1# Take day number2day = int(input("Enter day number (1-7): "))34# Print day name5if day == 1:6 print("Monday")7elif day == 2:8 print("Tuesday")9elif day == 3:10 print("Wednesday")11elif day == 4:12 print("Thursday")13elif day == 5:14 print("Friday")15elif day == 6:16 print("Saturday")17elif day == 7:18 print("Sunday")19else:20 print("Invalid day number")
Output
Enter day number (1-7): 3 Wednesday Enter day number (1-7): 7 Sunday
What's going on
Use elif chain to map numbers to day names.
Key Concepts:
Map each number (1-7) to corresponding day
Use elif for multiple conditions
Handle invalid input with else
🔗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