getting-started-with-lists/quickref.tex
changeset 342 588b681e70c6
parent 320 223044cf254f
equal deleted inserted replaced
341:9f7eb1ed0e08 342:588b681e70c6
     1 Creating a linear array:\\
     1 Creating an list\\
     2 {\ex \lstinline|    x = linspace(0, 2*pi, 50)|}
     2 {\ex \lstinline| empty=[]|}
     3 
     3 
     4 Plotting two variables:\\
     4 Create a filled list\\
     5 {\ex \lstinline|    plot(x, sin(x))|}
     5 {\ex \lstinline| nonempty = ['spam', 'eggs', 100, 1.234]  |}
     6 
     6 
     7 Plotting two lists of equal length x, y:\\
     7 Accessing a list\\
     8 {\ex \lstinline|    plot(x, y)|}
     8 {\ex \lstinline|    nonempty[0] |}
       
     9 {\ex \lstinline|    nonempty[-1] |}
       
    10 
       
    11 Length of a list\\
       
    12 {\ex \lstinline|    len(nonempty) |}
       
    13 
       
    14 Append an element to a list\\
       
    15 {\ex \lstinline|    nonempty.append('python') |}
       
    16 
       
    17 Remove elements of a list\\
       
    18 {\ex \lstinline|    del(nonempty[1] |}
       
    19 {\ex \lstinline|  nonempty.remove(100) |}