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 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
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
🔗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