day1/session2.tex
changeset 275 71e50184d482
parent 274 34f71bdd0263
child 276 4555c3814dd4
equal deleted inserted replaced
274:34f71bdd0263 275:71e50184d482
   258 \begin{lstlisting}
   258 \begin{lstlisting}
   259 In []: lst[1:3]  # A slice.
   259 In []: lst[1:3]  # A slice.
   260 Out[]: [2, 3]
   260 Out[]: [2, 3]
   261 
   261 
   262 In []: lst[1:-1]
   262 In []: lst[1:-1]
   263 Out[]: [2, 3]
   263 Out[]: [2, 3, 4]
   264 \end{lstlisting}
   264 \end{lstlisting}
   265 \alert{\typ{list[initial:final]}}
   265 \alert{\typ{list[initial:final]}}
   266 \end{frame}
   266 \end{frame}
   267 
   267 
   268 \begin{frame}[fragile]
   268 \begin{frame}[fragile]
   269 \frametitle{List operations}
   269 \frametitle{List operations}
   270 \begin{lstlisting}
   270 \begin{lstlisting}
   271 In []: anthrlst = [ 6, 7, 8, 9]
   271 In []: a = [ 6, 7, 8, 9]
   272 In []: lnglst = lst + anthrlst
   272 In []: b = lst + a
   273 
   273 
   274 In []: lnglst
   274 In []: b
   275 Out[]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
   275 Out[]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
   276 
   276 
   277 In []: lst.append(6)
   277 In []: lst.append(6)
   278 In []: lst
   278 In []: lst
   279 Out[]: [ 1, 2, 3, 4, 5, 6]
   279 Out[]: [ 1, 2, 3, 4, 5, 6]
   450 In []: type(points[0])
   450 In []: type(points[0])
   451 Out[]: <type 'str'>
   451 Out[]: <type 'str'>
   452   \end{lstlisting}
   452   \end{lstlisting}
   453 But, we need floating point numbers
   453 But, we need floating point numbers
   454   \begin{lstlisting}
   454   \begin{lstlisting}
   455 In []: t = float(point[0])
   455 In []: t = float(points[0])
   456 
   456 
   457 In []: type(t)
   457 In []: type(t)
   458 Out[]: <type 'float'>
   458 Out[]: <type 'float'>
   459   \end{lstlisting}
   459   \end{lstlisting}
   460 \end{frame}
   460 \end{frame}