print "Hello, Pylestras!" ? import collections collections.namedtuple? collections.Counter?? *int*? a = 1 + 2 print a a print In print Out %magic %timeit range(100) %%timeit s = 0 for i in range(10): s += i ** 2 %%bash echo "Meu path:" pwd %%ruby 6.times { puts 'Não faça isso em casa.' } %%javascript alert("Hello, Pylestras"); %lsmagic !ls files = !ls for f in files: if f.endswith('.ipynb'): print f python_variable = 42 !echo $python_variable !echo {"{0:#b}".format(python_variable)} %connect_info %qtconsole %matplotlib inline """ Demo of the fill function with a few features. In addition to the basic fill plot, this demo shows a few optional features: * Multiple curves with a single command. * Setting the fill color. * Setting the opacity (alpha value). """ import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2 * np.pi, 100) y1 = np.sin(x) y2 = np.sin(3 * x) plt.fill(x, y1, 'b', x, y2, 'r', alpha=0.3) fig = plt.gcf() %qtconsole from IPython.display import Image Image(url='http://python.org/images/python-logo.gif') Image('http://ipython.org/_static/IPy_header.png') from IPython.display import YouTubeVideo YouTubeVideo('kkwiQmGWK4c') from IPython.display import Audio import numpy as np import matplotlib.pyplot as plt max_time = 3 f1 = 220.0 f2 = 224.0 rate = 44100.0 L = 3 times = np.linspace(0,L,rate*L) signal = np.sin(2*np.pi*f1*times) + np.sin(2*np.pi*f2*times) Audio(data=signal, rate=rate) audio_plt = plt.plot(times, signal) from sympy import * init_printing() x = Symbol('x') (pi + x)**2 (x+1)*(x+2)*(x+3) expand((x+1)*(x+2)*(x+3)) from IPython.html.widgets import interact, interactive, fixed def f(x): print x interact(f, x=10); interact(f, x=True); interact(f, x='Hi there!'); @interact(x=True, y=1.0) def g(x, y): print(x, y) import skimage from skimage import data, filter, io from IPython.display import display i = data.coffee() lims = (0.0,1.0,0.01) def edit_image(image, sigma=0.1, r=1.0, g=1.0, b=1.0): new_image = filter.gaussian_filter(image, sigma=sigma, multichannel=True) new_image[:,:,0] = r*new_image[:,:,0] new_image[:,:,1] = g*new_image[:,:,1] new_image[:,:,2] = b*new_image[:,:,2] new_image = io.Image(new_image) display(new_image) return new_image w = interactive(edit_image, image=fixed(i), sigma=(0.0,10.0,0.1), r=lims, g=lims, b=lims) display(w) import pandas as pd ts = pd.Series(np.random.randn(10), index=pd.date_range('1/1/2014', periods=10)) df = pd.DataFrame(np.random.randn(10, 4), index=ts.index, columns=['A', 'B', 'C', 'D']) df = df.cumsum() df plt.figure() df.plot() plt.legend(loc='best') from IPython.display import IFrame IFrame('http://nbviewer.ipython.org/', 800, 600)