Logic Building
# Count numbers
count = 0
for num in range(1, 501):
if num % 7 == 0 and num % 5 != 0:
count += 1
print(f"Count: {count}")Output
Count: 57
Check both conditions with AND.
Key Concepts:
- Divisible by 7: num % 7 == 0
- Not divisible by 5: num % 5 != 0
- Count matching numbers