Complex Number Validation
Apply multiple conditions to validate number properties.
AdvancedPhase 6 - Category 1: Number LogicExample 1 of 10
complex-number-validation.py
1# Take a number2num = int(input("Enter a number: "))34# Check multiple conditions5is_positive = num > 06is_even = num % 2 == 07is_two_digit = 10 <= num <= 998sum_of_digits = sum(int(d) for d in str(num))9sum_is_even = sum_of_digits % 2 == 01011if is_positive and is_even and is_two_digit and sum_is_even:12 print("Number meets all criteria")13else:14 print("Number does not meet all criteria")
Output
Enter a number: 24 Number meets all criteria Enter a number: 25 Number does not meet all criteria
What's going on
Combine multiple conditions using logical operators.
Key Concepts:
Check multiple properties: positive, even, two-digit
Calculate sum of digits
Use AND to ensure all conditions met
Break complex logic into smaller checks
🔗Related Content
- 📖
Phase 6 - Learn Concepts
Review Phase 6 concepts and explanations
- 📝
Phase 6 - Quiz
Test your Phase 6 understanding with quiz questions
- 💻
Phase 6 - All Practice Problems
Explore all practice problems for Phase 6
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum