Let's evaluate some simple expressions.
3*2
5+3*2
You can use type()
to find the type of an expression.
type(5+3*2)
Now add decimal points.
5+3.5*2
type(5+3.0*2)
Strings are written with single ('
) or double quotes ("
)
"hello"
Multiplication and addition work on strings, too.
3 * 'hello' + "eagpggpu"
Lists are written in brackets ([]
) with commas (,
).
[5, 3, 7]
List entries don't have to have the same type.
["hi there", 15, [1,2,3]]
"Multiplication" and "addition" work on lists, too.
[1,2,3] * 4 + [5, 5, 5]
Hmmmmmm. Was that what you expected?
import numpy as np
np.array([1,2,3]) * 4 + np.array([5,5,5])