In [1]:
import sys
print(sys.version)
At this point anything above python 3.5 should be ok.
In [2]:
import numpy as np
print(np.__version__)
import matplotlib as mpl
from matplotlib import pyplot as plt
print(mpl.__version__)
In [3]:
x = [0,1,2,3,4,5,6]
a = [0.0, 1.0, 6.2, 5.333, 9, 4, 3.4]
b = np.array(a)
print(b)
print(type(b))
In [4]:
b = np.array(a)
print(b.sum())
print(b.mean())
In [5]:
#plot it
fig = plt.figure()
plt.plot(x,b)
plt.plot(x, [b.mean()] * len(x))
plt.show()
In [ ]:
In [6]:
print(np.zeros(5))
print(np.ones(5))
zeros = np.zeros((5,2))
print(zeros)
print(zeros.shape)
In [7]:
values = np.zeros(50)
size = values.shape
print(size)
for i in range(size[0]):
values[i] = i * 2
print(values)
Do the same for a two dimensional array
In [8]:
values = np.zeros((2,50))
size = values.shape
print(size)
for i in range(size[1]):
values[0,i] = i * 2
values[1,i] = i / 2
print(values)
In [ ]:
In [9]:
x = np.linspace(-np.pi, np.pi, num = 10)
print(x)
In [ ]: