Q. Given a 1D array, Write a program to replace all odd numbers with 1 and display the final array.
Answer :-
import numpy as np arr = np.array([7, 9, 3, 5, 19, 17]) arr[arr%2 == 1] = 1 print(arr)
import numpy as np arr = np.array([7, 9, 3, 5, 19, 17]) arr[arr%2 == 1] = 1 print(arr)
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )