Saturday, November 15, 2025
HomeLanguagesFind the position of number that is multiple of certain number

Find the position of number that is multiple of certain number

In this type of question, a number is given and we have to find the position or index of all multiples of that number. For doing this question we use a function named numpy.argwhere().

Syntax:

numpy.argwhere(array)

Example 1: 

Sometimes we need to find the indexes of the element that are divisible by int or float number.

Python3




# Importing Pandas and Numpy libraries
import pandas as pd
import numpy as np
  
# Creating a Series of random numbers
n_series = pd.Series(np.random.randint(1, 25, 15))
print("Original Series:\n")
print(n_series)
  
# Finding the indexes of numbers divisible by 3
res_index = np.argwhere(n_series % 3==0)
print("Positions of numbers that are multiples of 3:\n")
print(res_index)


Output:

In the above example, we find the indexes of all numbers divisible by 3.

Example 2:

Python3




# Importing Pandas and Numpy libraries
import pandas as pd
import numpy as np
  
# Creating a Series of random numbers
n_series = pd.Series(np.random.randint(1, 20, 10))
print("Original Series:\n")
print(n_series)
  
# Finding the indexes of numbers divisible by 3.5
res_index = np.argwhere(n_series % 3.5==0)
print("Positions of numbers that are multiples of 3.5:\n")
print(res_index)


Output:

In the above example, we find the indexes of all numbers divisible by floating-point number 3.5

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11985 POSTS0 COMMENTS
Shaida Kate Naidoo
6890 POSTS0 COMMENTS
Ted Musemwa
7143 POSTS0 COMMENTS
Thapelo Manthata
6838 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS