0
Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200.
The number obtained should be printed in a comma separated sequence on a single line
3 Respuestas
+ 5
Hi, this is the Q&A section. Here you can ask programming related questions. What is your question.
Pasting a task description is not asking a question.
If you need help, please link your code and describe the problem that you are facing.
0
It is a list comprehension with the filter not i%7 and i%5.
But you could also leave the i%7 .
first value is 2009 .
Then the list comprehension is 2009 + i*7 for I in range( 3200 - 2009)//7 if 2009+ i*7 %5
You might find out, that the walrus operator will speed up your code. But maybe it is not yet in your scope.
So you have choice between kiss (keep it simple stupid) and elaborated python. Anyway... a list comprehension seems tip9 be the right choice.
0
Because I'm feeling like an answer vending machine...
I mean, are you learning to code or just lazy?
print(*[i for i in range(2000, 3201) if i%7==0 and i%5!=0], sep=', ')