Given a range (which is 1 to 1000) and we have print all numbers which are divisible bye 7 and not divisible by 5 in python.
Example:
Input:
Given input range is 1 to 1000
Output:
7, 14, 21, 28, 42, 49, 56, ...
Logic:
- To implement this logic, we will use a for and in loop with range() method. The statement of range() method with the minimum to maximum range is range(begin, end+1).
- And, check the condition, that value should be divisible by 7 and should not be divisible by 5 (example code: ((cnt%7==0) and (cnt%5!=0)) ).
- If condition is true, print the numbers.
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer