Check Voting Eligibility
Check voting eligibility for a given age (18+).
IntermediatePhase 1 - Level 2: Nested If & Multiple ConditionsExample 6 of 10
check-voting-eligibility.py
1# Take age as input2age = int(input("Enter age: "))34# Check voting eligibility5if age >= 18:6 print("Eligible to vote")7else:8 print("Not eligible to vote")
Output
Enter age: 20 Eligible to vote Enter age: 16 Not eligible to vote
What's going on
Use >= operator to check if age is 18 or above.
Key Concepts:
Voting age is 18 or above
Use >= to include 18
Simple if-else structure
🔗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