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) }\\ |