Positive Numbers Sum Check

Take two numbers and check if both are positive and their sum is less than 100.

IntermediatePhase 1 - Level 4: Logical Operators & Compound StatementsExample 6 of 10
positive-numbers-sum-check.py
1# Take two numbers
2num1 = float(input("Enter first number: "))
3num2 = float(input("Enter second number: "))
4
5# Check conditions
6if num1 > 0 and num2 > 0 and (num1 + num2) < 100:
7 print("Both positive and sum < 100")
8else:
9 print("Condition not met")

Output

Enter first number: 30
Enter second number: 40
Both positive and sum < 100

Enter first number: 50
Enter second number: 60
Condition not met

What's going on

Check multiple conditions with AND.

Key Concepts:

Both numbers must be positive
Sum must be less than 100
Use AND to combine all conditions