Consider the following Python 3.7.2 code [*] i ran in IDLE (I have added line numbers for reference):
[1] >>>> a_tuple = (1,2,3)
[2] >>>> a_tuple
[3] (1,2,3)
[4] >>>> print(a_tuple)
[5] (1,2,3)
[6] >>>> an_ndarray = numpy.array([1,2,3])
[7] >>>> an_ndarray
[8] array([1, 2, 3])
[9] >>>> print(an_ndarray)
[10] [1, 2, 3]
I am learning computer science terminology and Python, and I have the following questions/requests:
ndarray
. It doesn't make sense, but it is as if what is returned is the function call to create it, except it lacks the numpy.
part.[1,2,3]
in [6] considered a list or just the syntax for numpy.array()
arguments?ndarray
without the array()
part in [8] and without using print()
?IDLE is an example of a Read-Eval-Print Loop, AKA REPL. You type a statement, it executes it, and if it's an expression with a value it prints the value.
a_tuple
. IDLE evaluated it and printed its value.ndarray
, which is a numpy array. The representation of numpy arrays is shown as the contents in square brackets inside array()
.[1, 2, 3]
is a list, being passed as the argument to the numpy.array()
function. numpy will then create an array whose contents are the elements of the list.ndarray.tolist()
.