Answer to Question #310294 in Python for xxx

Question #310294

Question 7

X = np.array([

[10,20,30], 

  [40,50,60], 

  [70,80,90]])

Answer:

print(X)

array([20, 50, 50])


Question 8

Y = np.array([

  [3,6,9,12], 

  [15,18,21,24], 

  [27,30,33,36], 

  [39,42,45,48],

  [51,54,57,60]])

Answer:


Question 8 Output

array([[ 3, 12],

    [27, 36],

    [51, 60]])


Question 9

print("Original array:")

Answer:

print(x)

>>>array([ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])

print(“Remove even numbers from the array x: “)

Answer:

print(x)

>>>array([12, 14, 16, 18, 200])

print(“Replace all odd numbers in array x with -10:”)

Answer:

print(x)

>>> array([ 12, -10, 14, -10, 16, -10, 18, -10, 20])


Question 10

print("Original array:")

Answer:

>>> print(X)

[10 12 14 16 18 20 22 24 26 28 30]

>>> print(Z)

[10 12 14 16 18 20 22 24 26 28 30]

Answer:

>>> print(X)

[0 2 4 6 18 20 22 24 26 28 30]

Answer:

>>> print(Z)

[10,12,14,16,-18,-20,-22,-24,26,28,30]


1
Expert's answer
2022-03-14T13:05:06-0400
def rem_even(list1):
    for i in list1:
        if i % 2 == 0:
            list1.remove(i)
    return list1
    
def rep_odd(list1):
    list2 = []
    for i in list1:
        if i % 2 != 0:
            list2.append(-10)
        else:
            list2.append(i)
    return list2


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS