Computer Science, asked by ahujavarun106, 1 day ago

Write a Program in Python, which accepts an numpy array of integer and divide all those array elements
by 7 which are divisible by 7 and multiply other array elements by 3.
class 12 pandas

Answers

Answered by cheemtu
0

import numpy as np

def func(array):

   return np.array([item if item%7 == 0 else item*3 for item in arr ])

arr = np.array([1,7,7,4,14,21,5]) #example

func(arr)    import numpy as np

   

   arr = np.array([1,7,7,4,14,21,5]) #example

   

   result = np.array([item if item%7 == 0 else item*3 for item in arr ])

Similar questions