FAQ: Introduction to NumPy - Operations with NumPy Arrays

This community-built FAQ covers the “Operations with NumPy Arrays” exercise from the lesson “Introduction to NumPy”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Science

Introduction to Statistics with NumPy

FAQs on the exercise Operations with NumPy Arrays

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

This assignment calls for us to update the array ‘test_3’ by adding 2 points to each element. Well, here’s the error message I got;

Expected “test_1_fixed” to be assigned a value

:confused:

Hi, correct me if I’m wrong, but it seems to me that the list example in this exercise is not the best way around this problem. I tried it this way and it seems to work out fine:

test_3_fixed = [x + 2 for x in test_3]

I get why arrays are very useful, but is it really necessary to overcomplicate things to make a point?

Cheers :beer:

import numpy as np

test_1 = np.array([92, 94, 88, 91, 87])

test_2 = np.array([79, 100, 86, 93, 91])

test_3 = np.array([87, 85, 72, 90, 92])

test_3_fixed=test_3+2

print(test_3_fixed)