ComeçarComece de graça

Operations with NumPy arrays

The following blocks of code create new lists given input lists input_list1, input_list2, input_list3 (you can check their values in the console). If you had analogous NumPy arrays with the same values input_array1, input_array2, input_array3 (you can check their values in the console), how would you create similar output as NumPy arrays using the knowledge on broadcasting, accessing element in NumPy arrays, and performing element-wise operations?

Block 1

list(map(lambda x: [5*i for i in x], input_list1))

Block 2

list(filter(lambda x: x % 2 == 0, input_list2))

Block 3

[[i*i for i in j] for j in input_list3]

Este exercício faz parte do curso

Practicing Coding Interview Questions in Python

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Substitute the code in the block 1 given the input_array1
output_array1 = ____
print(list(map(lambda x: [5*i for i in x], input_list1)))
print(output_array1)
Editar e executar o código