+ 1

How one go about this?

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 (both included) the numbers obtained should be printed in a comma separated sequence on a single line from largest to the smallest

16th Jun 2017, 8:42 PM
Obumneme Anichebe
Obumneme Anichebe - avatar
6 Respuestas
0
nums=[i for i in range(2000,3200) if i%7==0] nums=[i for i in nums if i%5!=0] nums=nums[::-1] for i in nums: print(i, end=',')
16th Jun 2017, 9:08 PM
LordHill
LordHill - avatar
+ 4
print([i for i in range(3200, 1999, -1) if ((i % 7 == 0) and (i % 5 != 0))]) Sorry for getting straight to it, though... :)
16th Jun 2017, 9:01 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
Well, I would have done: print(', '.join(sorted([k for k in range(2000, 3201) if not k % 7 and k % 5])) but that is not a really pretty code...
17th Jun 2017, 8:40 PM
Amaras A
Amaras A - avatar
0
With a given integral number n, write a program to generate a dictionary that contains (I, i*I) such that is an integral number between 1 and n (both included) and the program should print dictionary
16th Jun 2017, 9:48 PM
Obumneme Anichebe
Obumneme Anichebe - avatar
0
come on now, we can't do all your homework
16th Jun 2017, 10:25 PM
LordHill
LordHill - avatar
0
and Kuba answer is the best answer. my code does the same thing his does, but his does it more efficiently. Might as well point the best answer nod his way. If I had saw he posted a solution I wouldn't have bothered. altho, the request was to print the numbers in a single line separated by commas. I did get him there, he just printed the list. Victory is mine! Jk, Kuba is much better at this than I am. He often makes me a better programmer simply by seeing how he tackles a problem differently than I
16th Jun 2017, 10:28 PM
LordHill
LordHill - avatar