Numbers Divisible by 7
Print numbers between a and b divisible by 7.
IntermediatePhase 2 - Level 3: Mathematical & Logical PatternsExample 3 of 13
numbers-divisible-by-7.py
1# Take range2a = int(input("Enter a: "))3b = int(input("Enter b: "))45# Print divisible by 76print(f"Numbers divisible by 7 between {a} and {b}:")7for i in range(a, b + 1):8 if i % 7 == 0:9 print(i, end=" ")10print()
Output
Enter a: 10 Enter b: 50 Numbers divisible by 7 between 10 and 50: 14 21 28 35 42 49
What's going on
Check each number in range for divisibility.
Key Concepts:
Loop through range a to b
Check if divisible by 7 using modulo
Print if condition met
🔗Related Content
- 📖
Phase 2 - Learn Concepts
Review Phase 2 concepts and explanations
- 📝
Phase 2 - Quiz
Test your Phase 2 understanding with quiz questions
- 💻
Phase 2 - All Practice Problems
Explore all practice problems for Phase 2
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum