day1/Session-1.tex
changeset 108 324b617ce8cd
parent 106 7b539cba0f04
equal deleted inserted replaced
107:647239f95c4a 108:324b617ce8cd
   505   \begin{lstlisting}
   505   \begin{lstlisting}
   506 In [6]: a.split()
   506 In [6]: a.split()
   507 Out[6]: ['hello', 'world']
   507 Out[6]: ['hello', 'world']
   508 In [7]: ''.join(['a', 'b', 'c'])
   508 In [7]: ''.join(['a', 'b', 'c'])
   509 Out[7]: 'abc'
   509 Out[7]: 'abc'
   510 In [8] 'd' in ''.join( 'a', 'b', 'c')
   510 In [8] 'd' in ''.join(['a', 'b', 'c'])
   511 Out[8]: False
   511 Out[8]: False
   512   \end{lstlisting}
   512   \end{lstlisting}
   513   \begin{block}{Try:}
   513   \begin{block}{Try:}
   514     \texttt{a.split( 'o' )}\\
   514     \texttt{a.split( 'o' )}\\
   515     \texttt{'x'.join( a.split( 'o' ) )}
   515     \texttt{'x'.join( a.split( 'o' ) )}
   516   \end{block}
   516   \end{block}
   517 \end{frame}
   517 \end{frame}
   518 
   518 
   519 \begin{frame}[fragile]\frametitle{String formatting}
   519 \begin{frame}[fragile]\frametitle{String formatting}
   520   \begin{lstlisting}
   520   \begin{lstlisting}
   521 In [11]: x, y = 1, 1.2
   521 In [11]: x, y = 1, 1.234
   522 In [12]: 'x is %s, y is %s' %(x, y)
   522 In [12]: 'x is %s, y is %s' %(x, y)
   523 Out[12]: 'x is 1, y is 1.234'
   523 Out[12]: 'x is 1, y is 1.234'
   524   \end{lstlisting}
   524   \end{lstlisting}
   525   \begin{block}{Try:}
   525   \begin{block}{Try:}
   526     \texttt{'x is \%d, y is \%f' \%(x, y) }\\
   526     \texttt{'x is \%d, y is \%f' \%(x, y) }\\
   566 In [21]: a = 7
   566 In [21]: a = 7
   567 In [22]: b = 8
   567 In [22]: b = 8
   568 In [23]: if a > b:
   568 In [23]: if a > b:
   569    ....:    print 'Hello'
   569    ....:    print 'Hello'
   570    ....: else:
   570    ....: else:
   571    ....:     print 'World'
   571    ....:    print 'World'
   572    ....:
   572    ....:
   573    ....:
   573    ....:
   574 World
   574 World
   575   \end{lstlisting}
   575   \end{lstlisting}
   576   Let us switch to creating a file
   576   Let us switch to creating a file