In [1]:
pwd


Out[1]:
u'/Users/sukruhasdemir/Dropbox/python-study/ipython-book'

In [2]:
%lsmagic


Available line magics:
%alias  %alias_magic  %autocall  %automagic  %bookmark  %cd  %clear  %colors  %config  %connect_info  %debug  %dhist  %dirs  %doctest_mode  %ed  %edit  %env  %gui  %hist  %history  %install_default_config  %install_ext  %install_profiles  %killbgscripts  %less  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %lsmagic  %macro  %magic  %man  %more  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %popd  %pprint  %precision  %profile  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx  %reload_ext  %rep  %rerun  %reset  %reset_selective  %run  %save  %sc  %store  %sx  %system  %tb  %time  %timeit  %unalias  %unload_ext  %who  %who_ls  %whos  %xdel  %xmode

Available cell magics:
%%!  %%bash  %%capture  %%file  %%perl  %%prun  %%ruby  %%script  %%sh  %%sx  %%system  %%timeit

Automagic is ON, % prefix IS NOT needed for line magics.

In [3]:
a = 12

In [4]:
a**2


Out[4]:
144

In [8]:
print "The result is {0:d}.".format(_7)


The result is 1728.

In [7]:
a**3


Out[7]:
1728


In [9]:
import os

In [ ]:
os.path.split._


In [10]:
timeit [x**2 for x in range(100000)]


100 loops, best of 3: 9.32 ms per loop

In [11]:
9/0


---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-11-dee41f0530bc> in <module>()
----> 1 9/0

ZeroDivisionError: integer division or modulo by zero

In [13]:
pylab


Welcome to pylab, a matplotlib-based Python environment [backend: MacOSX].
For more information, type 'help(pylab)'.

In [15]:
x = linspace(-10., 10., 1000)

In [17]:
plot(x, sin(x))


Out[17]:
[<matplotlib.lines.Line2D at 0x107fcea90>]

In [22]:
a = ones(6); a


Out[22]:
array([ 1.,  1.,  1.,  1.,  1.,  1.])

In [19]:
import numpy as np

In [23]:
b = np.ones(6); b


Out[23]:
array([ 1.,  1.,  1.,  1.,  1.,  1.])

In [31]:
c = type(a) == type(b)

In [32]:
c


Out[32]:
True


In [92]:
ranges = np.array([0.79, 0.70, 0.73, 0.66, 0.65, 0.70, 0.74, 0.81, 0.71, 0.70])
mu = np.mean(ranges)

In [93]:
var = np.var(ranges)
N = len(ranges)
c = 1.96 * np.sqrt(var/N)

In [94]:
low = mu - c
high = mu +c
print low, high


0.689088319338 0.748911680662


In [102]:
15.5/16


Out[102]:
0.96875

In [96]:
4./3 - 1.3333


Out[96]:
3.333333333332966e-05

In [100]:
-5./3


Out[100]:
-1.6666666666666667

In [ ]: