Session Ready
Exercise

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]
Instructions 1/3
undefined XP
  • 1
    • Substitute the code in the block 1 given the input_array1.
    • 2
      • Substitute the code in the block 2 given input_array2.
    • 3
      • Substitute the code in the block 3 given input_array3.