+ 1

How can I make a function that can filter numbers according to their multiples

It can filter numbers by their multiples

13th Sep 2020, 4:25 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar
8 ответов
+ 4
There is already a filter function in python. Can you explain what is the expected input and output?
13th Sep 2020, 4:30 PM
Tibor Santa
Tibor Santa - avatar
+ 6
if you will do this code, you need to decide: - input numbers from x up to y if you have to create the numbers - how to handle duplicates in the result. so 10 is a multiple of 2 and also of 5, or 30 is a multiple of 2, 3 and 5. - if you get some numbers as list input, you can use filter or a for loop or a comprehension.
13th Sep 2020, 7:02 PM
Lothar
Lothar - avatar
+ 4
Kintu Michael Evans , please do ask other people for doing your work. You should do a try by yourself first. Take your code and put it in playground and link it here. Thanks!
13th Sep 2020, 6:43 PM
Lothar
Lothar - avatar
+ 4
What you have to do is use list comprehension. E.g Lets look for multiples of 3 >>>multiples_of_three = [i for i in range(20) if i%3==0] >>>print(multiples_of_three)
15th Sep 2020, 8:41 PM
Akatwijuka Allan
Akatwijuka Allan - avatar
+ 3
I am solving a code coach
13th Sep 2020, 4:37 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar
+ 2
I want to make a function that can list multiples of 2,3,4 and 5
13th Sep 2020, 4:34 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar
+ 2
Use the modulo operator. For example 8%2=0 this means that 8 is a multiple of 2.
13th Sep 2020, 4:35 PM
Tibor Santa
Tibor Santa - avatar
+ 2
Make an example code
13th Sep 2020, 4:36 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar