import numpy as np
%%capture timeit_results
# Regular Python
%timeit python_list_1 = range(1,1000)
python_list_1 = range(1,1000)
python_list_2 = range(1,1000)
#Numpy
%timeit numpy_list_1 = np.arange(1,1000)
numpy_list_1 = np.arange(1,1000)
numpy_list_2 = np.arange(1,1000)
print(timeit_results)
1000000 loops, best of 3: 223 ns per loop The slowest run took 12.37 times longer than the fastest. This could mean that an intermediate result is being cached. 1000000 loops, best of 3: 996 ns per loop
%%capture timeit_python
%%timeit
# Regular Python
[(x + y) for x, y in zip(python_list_1, python_list_2)]
[(x - y) for x, y in zip(python_list_1, python_list_2)]
[(x * y) for x, y in zip(python_list_1, python_list_2)]
[(x / y) for x, y in zip(python_list_1, python_list_2)];
print( timeit_python)
1000 loops, best of 3: 273 us per loop
%%capture timeit_numpy
%%timeit
#Numpy
numpy_list_1 + numpy_list_2
numpy_list_1 - numpy_list_2
numpy_list_1 * numpy_list_2
numpy_list_1 / numpy_list_2;
print( timeit_numpy)
The slowest run took 62.71 times longer than the fastest. This could mean that an intermediate result is being cached. 100000 loops, best of 3: 5.26 us per loop
!pwd
%lsmagic
%matplotlib inline
"""
Demo of bar plot on a polar axis.
"""
import numpy as np
import matplotlib.pyplot as plt
N = 20
theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)
radii = 10 * np.random.rand(N)
width = np.pi / 4 * np.random.rand(N)
ax = plt.subplot(111, projection='polar')
bars = ax.bar(theta, radii, width=width, bottom=0.0)
# Use custom colors and opacity
for r, bar in zip(radii, bars):
bar.set_facecolor(plt.cm.jet(r / 10.))
bar.set_alpha(0.5)
plt.show()
%%HTML
<HTML>
<HEAD>
<TITLE>
A Small Hello
</TITLE>
</HEAD>
<BODY>
<H1>Hi</H1>
<P>This is very minimal "hello world" HTML document.</P>
</BODY>
</HTML>
This is very minimal "hello world" HTML document.
%%HTML
<iframe width="560" height="315" src="https://www.youtube.com/embed/IVrGz8w0H8c" frameborder="0" allowfullscreen></iframe>
print("hello")
hello
%%timeit
10*10
100000000 loops, best of 3: 10.6 ns per loop
## another sample