Q. Consider an Array A containing Numeric values- Write a program to replace all odd numbers with -1 and copy this content into another array B without altering the original array A.
Answer :-
import numpy as np A = np.array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) print(A) B = A.copy() B[B%2 == 1] = -1 print(B)
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )