Last answered:

05 Oct 2021

Posted on:

01 Jul 2021

0

Resolved: Mathematics: scalars, vectors and Matrices as Python Arrays

When I was running codes in the lesson, like:
s = 5
s
Error is shown below:
image.png
This happens when I was running every code in this lesson.

1 answers ( 1 marked as helpful)
Instructor
Posted on:

05 Oct 2021

1

Hello Longyin,

Thank you for your question and for the picture provided. The reason behind the error is in the way you run the Jupyter cells - I assume that you first type some of the code and then only run the last cell. However, whilst in the process of writing the code, you need to run every cell in a consequtive manner. In the example photo, you should first run the cell import numpy as np, then s = 5 + 3 and finally the last one.
-----------------------
As a rule of thumb, you can easily see which cells have already been run and in what order. Notice the In [ ] to the immediate left of each cell. In the example photo, only the last cell has square brackets with a number inside, which is '1', whereas all other square brackets are empty. This means that the previous cells have not been run (therefore the variable 's' is indeed undefined). If there is a number in the square brackets, it means the cell has been run; moreover, the numbers are in growing order, so you can always know in what succession you have run the Jupyter cells.

Hope this helps!
A., The 365 Team

Submit an answer