First things first: how do I get some help?
?
%quickref
%magic
%alias?
!pwd
/home/fperez/teach/reprosw
Tab completion!
import numpy as np
np
<module 'numpy' from '/home/fperez/usr/opt/lib/python2.7/site-packages/numpy/__init__.pyc'>
2+3
5
_ **2
25
2**100
1267650600228229401496703205376L
def factorial(n):
if n==0:
return 1
return n*factorial(n-1)
factorial(10)
3628800
import this
The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
This imports numpy as np
and matplotlib's plotting routines as plt
, plus setting lots of other stuff for you to work interactivel very easily:
%pylab inline
Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline]. For more information, type 'help(pylab)'.
x = np.linspace(0, np.pi, 200)
y = np.sin(x**2)
plt.plot(x, y)
[<matplotlib.lines.Line2D at 0x43f8890>]