<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Topics
We will cover
Step1:  Exploring modules -- getting help
If you do not know what is available inside a module you can get help
by hitting < tab >.
Step2:  To get help with a particular function, type math.sin?
Step4:  A notebook can display (nearly) anything
Because the notebook runs in your browser it can display nearly anything. Basically
anything your browser can display is allowed.
Step5:  Custom objects
You can teach your own classes how to display themselves! Read the Rich display help.
Step6:  Inline plots
You can display your plots right next to the code that made them.
Step7:  Interactive interactive plots (twice as interactive!)
IPython makes it super easy to build little webapps
<ASSISTANT_TASK:>
Python Code:
import math
print("The square root of 3 is:", math.sqrt(3))
print("π is:", math.pi)
print("The sin of 90 degrees is:", math.sin(math.radians(90)))
Explanation: Topics
We will cover:
Basic math
Exploring modules and getting help
Rich displaying
Inline plots
Interactive inline plots
Interactive elements
Basic math
Let's do some basic math to get everyone started:
End of explanation
math.
Explanation: Exploring modules -- getting help
If you do not know what is available inside a module you can get help
by hitting < tab >.
End of explanation
math.erf?
s = "Hello!"
s.join() # or press <shift>+<tab> inside the brackets
Explanation: To get help with a particular function, type math.sin?
End of explanation
from IPython.display import Image
Image('imgs/leonardo.jpg')
# HTML
from IPython.display import HTML
HTML('<b>Hello world!</b>')
# Artsy videos
from IPython.display import VimeoVideo
VimeoVideo("150594088")
# LaTeX!
from IPython.display import Latex
Latex(r\begin{eqnarray}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, 
\frac{\partial\vec{\mathbf{E}}}{\partial t} & = & \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = & 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, 
\frac{\partial\vec{\mathbf{B}}}{\partial t} & = & \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = & 0 
\end{eqnarray})
Explanation: A notebook can display (nearly) anything
Because the notebook runs in your browser it can display nearly anything. Basically
anything your browser can display is allowed.
End of explanation
class Apple:
    def __init__(self, colour):
        self.colour = colour
    def _repr_html_(self):
        if self.colour == 'green':
            url = ("https://www.infusioneliquid.com/wp-content"
                  "/uploads/2013/12/Green-Apples.jpg")
        elif self.colour == 'red':
            url = ("http://boutonrougedesigns.com/wp-content"
                   "/uploads/red-apple.jpg")
            
        else:
            url = ("http://static1.squarespace.com/static"
                   "/51623c20e4b01df404d682ae/t/542d5d05e4b09d76c5f801d8"
                   "/1412259082640/Be+the+job+candidate+that+stands+out+"
                   "from+the+rest+and+the+one+recruitment+consultants+choose+jpeg")
        return "<img src=%s />"%url        
Apple("red")
Explanation: Custom objects
You can teach your own classes how to display themselves! Read the Rich display help.
End of explanation
# Matplotlib
%config InlineBackend.figure_format='retina'
# gives you interactive plots
%matplotlib notebook
# rendered inline plots
#%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (6, 6)
plt.rcParams["figure.max_open_warning"] = -1
# Taken from https://github.com/fperez/talk-1504-boulder/blob/master/QuickTour.ipynb
from scipy import special
import numpy as np
def plot_bessel(xmax=20, nmin=0, nmax=10, nstep=3):
    x = np.linspace(0, xmax, 200)
    f, ax = plt.subplots()
    for n in range(nmin, nmax+1, nstep):
        plt.plot(x, special.jn(n, x), label=r'$J_{%i(x)}$' % n)
    plt.grid()
    plt.legend()
    plt.title('Bessel Functions')
plot_bessel()
Explanation: Inline plots
You can display your plots right next to the code that made them.
End of explanation
from IPython.html.widgets import interact
interact(plot_bessel, xmax=(10,100.), nmin=(0, 10),
         nmax=(10, 30), nstep=(1,5));
Explanation: Interactive interactive plots (twice as interactive!)
IPython makes it super easy to build little webapps:
End of explanation
<END_TASK>