In [1]:
# using the notebook
1 + 1
Out[1]:
In [2]:
# variables
a = 2
b = a * 3
print(b)
In [12]:
# lists
my_list = [1, "hi", [2, 3]]
In [13]:
print(my_list[0])
In [14]:
print(my_list[-1])
In [6]:
# loops
for item in my_list:
print(item)
In [8]:
# conditionals
value = 5
if value > 3:
print("{0} > 3".format(value))
else:
print("{0} <= 3".format(value))
In [9]:
# arrays
import numpy as np
my_array = np.array([1.0, 2.3, 3.5])
In [10]:
print(my_array)
In [11]:
print(my_array[0])
In [16]:
print(my_array[:2])
In [17]:
print(my_array.shape)
In [18]:
print(np.arange(10))
In [3]:
array_2d = np.reshape(np.arange(6), (2, 3))
In [4]:
print(array_2d)
In [5]:
print(array_2d[0])
In [6]:
# NBVAL_IGNORE_OUTPUT
print(array_2d[1, 1])
In [30]:
print(array_2d.shape)
In [31]:
print(array_2d * my_array)
In [32]:
print(array_2d + my_array)
In [1]:
# plotting
%matplotlib inline
import matplotlib.pyplot as plt
x = np.random.random(100)
plt.plot(x);
In [2]:
data = np.random.random((100, 100))
plt.imshow(data);
In [ ]: