In: Computer Science
using python 3
2. Write a python program that finds the numbers that are divisible by both 2 and 7 but not 70, or that are divisible by 57 between 1 and 1000.
3. Write a function called YesNo that receives as input each of the numbers between 1 and 1000 and returns True if the number is divisible by both 2 and 7 but not 70, or it is divisible by 57. Otherwise it returns False.
4. In your main Python program write a for loop that counts from 1 to 1000 and calls this YesNo function inside the for loop and will print "The number xx is divisible by both 2 and 7 but not 70, or that are divisible by 57" if the YesNo function returns True. Otherwise it prints nothing. Note the print statement also prints the number where the xx is above.
def YesNo(n):
#checking divisable by 2 and 7 not by 70 or by 57
return (n%2==0 and n%7==0 and n%70!=0) or n%57==0
if __name__ == '__main__':
#iterating from 1-1000
for x in range(1,1001):
#if YesNo returns true than print
if YesNo(x):
print("he number ",x," is divisible by both 2 and 7 but not 70, or that are divisible by 57")
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me