ipython.pdf

(1854 KB) Pobierz
Algorithms  and  Data  Structures  
IPython  
Łódź
2012
IPython  –  ipython.org  
M Kociński & A Materka, Algorithms & Data Structures, TUL IFE,
Łódź
2012
IPython  
Mac OS
M Kociński & A Materka, Algorithms & Data Structures, TUL IFE,
Łódź
2012
PyLab  –  Interac<ve  Python  
Enviroment  
x  =  arange(100.)  
 
plot(x,sin(x*pi/50))  
#Now  change  display  op<on  
hold(False)  
plot(x,cos(x*pi/50))  
#  and  
hold(True)  
plot(x,sin(x*pi/50))  
plot(x,cos(x*pi/50))  
 
 
M Kociński & A Materka, Algorithms & Data Structures, TUL IFE,
Łódź
2012
IPython  Introducion  
STANDARD  PYTHON  
In  [1]:      a=1  
In  [2]:      a  
Out  [2]:      1  
 
AVALIABLE  VARIABLES  
In  [3]:      b  =  [1,2,3]  
 
#  Comments  #  (to  the  end  of  the  line)  
WARNING:    %reset  also  removes  the  names  imported  
#  List  available  variables  
by  PyLab.  
In  [4]:      %whos  
In  [7]:  plot  
 
NameError:  name  'plot'  is  not  defined  
Variable      Type        Data/Info  
#  Reload  
-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐  
In  [8]:  %pylab  
a                    int          1  
Welcome  to  pylab,  a  matplotlib-­‐based  Python  
b                    list        n=3  
environment…  
M Kociński & A Materka, Algorithms & Data Structures, TUL IFE,
Łódź
2012
 
 
 
 
RESET  &  RELOAD  
#  Reset  user  defined  variables  
In  [5]:  %reset  
Once  deleted,  variables  cannot  be  recovered.  Proceed  
(y/[n])?    y  
 
#  Let’s  check  our  namespace  
In  [6]:  %whos  
Interac(ve  namespace  is  empty.  
Zgłoś jeśli naruszono regulamin