Positive Numbers Sum Check
Check that two numbers are positive and their sum is below one hundred. A Python exercise on three linked tests, strict boundaries, and failed conditions.
1# Take two numbers2num1 = float(input("Enter first number: "))3num2 = float(input("Enter second number: "))45# Check conditions6if 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
In this one
- Require three conditions
- Test a strict sum limit
- Reject zero as positive
How it works
- 1
Read both values as floats.
- 2
Check each is positive and their sum below one hundred.
- 3
Print the combined-condition result.
Edge cases
Does 40 and 60 pass?
Does 40 and 60 pass?
No. A sum of exactly one hundred is excluded.
Does 0 and 20 pass?
Does 0 and 20 pass?
No. Zero is not strictly positive.
What's going on
The pair must meet three requirements at once. Both individual values must exceed zero, and their combined value must be less than one hundred.
and rejects the pair as soon as a requirement fails. With 30 and 40, all tests pass. With 50 and 60, the values are positive but their sum is too large. Checking only the sum would wrongly allow some negative inputs.
Does 40 and 60 pass? No. A sum of exactly one hundred is excluded.
Does 0 and 20 pass? No. Zero is not strictly positive.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
Which pair meets all conditions?
Pick an answer to check it.
Question 2
Does 40 and 60 pass?
Pick an answer to check it.
Questions people ask
Does 40 and 60 pass?
No. A sum of exactly one hundred is excluded.
Does 0 and 20 pass?
No. Zero is not strictly positive.
Which pair meets all conditions?
30 and 40.
๐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