day1/cheatsheet2.tex
changeset 340 347ff2714deb
parent 314 c9f05808e1c4
child 341 7ae88b9da553
equal deleted inserted replaced
329:0a6ab1d81491 340:347ff2714deb
   117 In []: greet = ``hello world''
   117 In []: greet = ``hello world''
   118 In []: print greet.split()
   118 In []: print greet.split()
   119 Out[]: ['hello', 'world']
   119 Out[]: ['hello', 'world']
   120 In []: greet = ``hello, world''
   120 In []: greet = ``hello, world''
   121 In []: print greet.split(',')
   121 In []: print greet.split(',')
   122 Out[]: ['hello', ' world'] # Note the whitespace before 'world'
   122 Out[]: ['hello', ' world'] # Note the white space before 'world'
   123 \end{lstlisting}
   123 \end{lstlisting}
   124 A string can be split based on the delimiter specified within quotes. A combination of more than one delimiter can also be used.\\
   124 A string can be split based on the delimiter specified within quotes. A combination of more than one delimiter can also be used.\\
   125 \typ{In []: greet.split(', ')}\\
   125 \typ{In []: greet.split(', ')}\\
   126 \typ{Out[]: ['hello', 'world']}\\Note the whitespace is not there anymore.
   126 \typ{Out[]: ['hello', 'world']}\\Note the white space is not there anymore.
   127 \newpage
   127 \newpage
   128 \section{Plotting from Files}
   128 \section{Plotting from Files}
   129 \subsection{Opening files}
   129 \subsection{Opening files}
   130 
   130 
   131 \typ{In []: f = open('datafile.txt')}\\By default opens in read mode. \\If file does not exist then it throws an exception\\
   131 \typ{In []: f = open('datafile.txt')}\\By default opens in read mode. \\If file does not exist then it throws an exception\\