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 number
2num = int(input("Enter a number: "))
3
4# Check multiple conditions
5is_positive = num > 0
6is_even = num % 2 == 0
7is_two_digit = 10 <= num <= 99
8sum_of_digits = sum(int(d) for d in str(num))
9sum_is_even = sum_of_digits % 2 == 0
10
11if 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