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

25th Nov 2022, 11:17 AM
Susheela
Susheela - avatar
3 Antworten
+ 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.
25th Nov 2022, 11:36 AM
Lisa
Lisa - avatar
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.
25th Nov 2022, 6:48 PM
Oma Falk
Oma Falk - avatar
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=', ')
26th Nov 2022, 4:26 AM
Bob_Li
Bob_Li - avatar