getting-started-with-lists/script.rst.orig
author Puneeth Chaganti <punchagan@fossee.in>
Wed, 17 Nov 2010 23:24:57 +0530
changeset 521 88a01948450d
parent 442 a9b71932cbfa
permissions -rw-r--r--
Merged heads.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
     1
.. Objectives
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
     2
.. ----------
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     3
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
     4
.. By the end of this tutorial, you will be able to
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
     5
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
     6
.. Create Lists.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
     7
.. Access List elements.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
     8
.. Append elemets to list
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
     9
.. Delete list elemets
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    10
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    11
.. 1. getting started with ipython 
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    12
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    13
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    14
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    15
.. Prerequisites
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    16
.. -------------
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    17
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    18
..   1. getting started with strings
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    19
..   #. getting started with lists
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    20
..   #. basic datatypes
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    21
     
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    22
.. Author              : Amit 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    23
   Internal Reviewer   : Anoop Jacob Thomas <anoop@fossee.in>
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    24
   External Reviewer   :
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    25
   Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    26
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    27
.. #[[Anoop: Slides contain only outline and summary
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    28
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    29
Script
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    30
------
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    31
 {{{ Show the slide containing title }}}
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    32
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    33
Hello friends and welcome to the tutorial on getting started with
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    34
lists.
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    35
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    36
 {{{ Show the slide containing the outline slide }}}
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    37
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    38
In this tutorial we will be getting acquainted with a python data
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    39
structure called lists.  We will learn ::
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    40
 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    41
 * How to create lists
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    42
 * Structure of lists
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    43
 * Access list elements
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    44
 * Append elements to lists
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    45
 * Delete elements from lists
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    46
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    47
List is a compound data type, it can contain data of other data
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    48
types. List is also a sequence data type, all the elements are in
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    49
order and the order has a meaning.
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    50
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    51
.. #[[Anoop: "all the elements are in order and **there** order has a
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    52
   meaning." - I guess something is wrong here, I am not able to
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    53
   follow this.]]
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    54
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    55
We will first create an empty list with no elements. On your IPython
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    56
shell type ::
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    57
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    58
   empty = [] 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    59
   type(empty)
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    60
   
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    61
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    62
This is an empty list without any elements.
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    63
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    64
.. #[[Anoop: the document has to be continous, without any
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    65
   subheadings, removing * Filled lists]]
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    66
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    67
Lets now see how to define a non-empty list. We do it as,::
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    68
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    69
     nonempty = ['spam', 'eggs', 100, 1.234]
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    70
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    71
Thus the simplest way of creating a list is typing out a sequence 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    72
of comma-separated values (items) between square brackets. 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    73
All the list items need not be of the same data type.
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    74
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    75
As we can see lists can contain different kinds of data. In the
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    76
previous example 'spam' and 'eggs' are strings and 100 and 1.234 are
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    77
integer and float. Thus we can put elements of heterogenous types in
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    78
lists including list itself.
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    79
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    80
.. #[[Anoop: the sentence "Thus list themselves can be one of the
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    81
   element types possible in lists" is not clear, rephrase it.]]
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    82
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    83
Example ::
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    84
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    85
      listinlist=[[4,2,3,4],'and', 1, 2, 3, 4]
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    86
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    87
We access list elements using the index. The index begins from 0. So
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    88
for list nonempty, nonempty[0] gives the first element, nonempty[1]
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    89
the second element and so on and nonempty[3] the last element. ::
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    90
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    91
	    nonempty[0] 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    92
	    nonempty[1] 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    93
	    nonempty[3]
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    94
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    95
Following is an exercise that you must do. 
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    96
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    97
%% %% What happens when you do nonempty[-1]. 
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
    98
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
    99
Please, pause the video here. Do the exercise and then continue.  
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   100
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   101
.. #[[Anoop: was negative indices introduced earlier, if not may be we
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   102
   can ask them to try out nonempty[-1] and see what happens and then
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   103
   tell that it gives the last element in the list.]]
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   104
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   105
As you can see you get the last element which is 1.234.
418
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   106
8a42b4203f6d "Merging heads"
Amit Sethi
parents:
diff changeset
   107
442
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   108
In python negative indices are used to access elements from the end::
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   109
   
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   110
   nonempty[-1] 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   111
   nonempty[-2] 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   112
   nonempty[-4]
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   113
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   114
-1 gives the last element which is the 4th element , -2 second to last
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   115
and -4 gives the fourth from last element which is first element.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   116
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   117
We can append elements to the end of a list using append command. ::
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   118
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   119
   nonempty.append('onemore') 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   120
   nonempty
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   121
   nonempty.append(6) 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   122
   nonempty
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   123
   
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   124
Following are  exercises that you must do. 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   125
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   126
%% %% What is the syntax to get the element 'and' 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   127
in the list,listinlist ?
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   128
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   129
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   130
%% %% How would you get 'and' using negative indices?
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   131
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   132
Please, pause the video here. Do the exercise and then continue.  
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   133
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   134
The solution is on your screen
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   135
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   136
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   137
As we can see non empty appends 'onemore' and 6 at the end.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   138
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   139
Using len function we can check the number of elements in the list
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   140
nonempty. In this case it 6 ::
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   141
	 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   142
	 len(nonempty)
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   143
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   144
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   145
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   146
Just like we can append elements to a list we can also remove them.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   147
There are two ways of doing it. One is by using index. ::
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   148
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   149
      del(nonempty[1])
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   150
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   151
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   152
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   153
deletes the element at index 1, 'eggs' which is the second element of
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   154
the list. The other way is removing element by content. Lets say one
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   155
wishes to delete 100 from nonempty list the syntax of the command
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   156
should be
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   157
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   158
.. #[[Anoop: let x = [1,2,1,3]
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   159
   	     now x.remove(x[2])
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   160
	     still x is [2,1,3] so that is not the way to remove
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   161
	     element by index, it removed first occurrence of 1(by
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   162
	     content) and not based on index, so make necessary
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   163
	     changes]]
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   164
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   165
::
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   166
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   167
    nonempty.remove(100)
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   168
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   169
but what if there were two 100's. To check that lets do a small
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   170
experiment. ::
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   171
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   172
	   nonempty.append('spam') 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   173
	   nonempty
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   174
	   nonempty.remove('spam') 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   175
	   nonempty
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   176
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   177
If we check now we will see that the first occurence 'spam' is removed
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   178
thus remove removes the first occurence of the element in the sequence
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   179
and leaves others untouched.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   180
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   181
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   182
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   183
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   184
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   185
.. #[[Anoop: does it have two spams or two pythons?]]
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   186
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   187
.. #[[Anoop: there are no exercises/solved problems in this script,
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   188
   add them]]
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   189
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   190
Following are  exercises that you must do. 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   191
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   192
%% %% Remove the third element from the list, listinlist.   
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   193
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   194
%% %% Remove 'and' from the list, listinlist.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   195
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   196
Please, pause the video here. Do the exercise and then continue.  
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   197
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   198
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   199
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   200
{{{Slide for Summary }}}
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   201
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   202
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   203
In this tutorial we came across a sequence data type called lists. ::
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   204
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   205
 * We learned how to create lists.  
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   206
 * How to access lists.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   207
 * Append elements to list.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   208
 * Delete Element from list.  
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   209
 * And Checking list length.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   210
 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   211
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   212
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   213
{{{ show Sponsored by Fossee Slide }}}
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   214
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   215
This tutorial was created as a part of FOSSEE project.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   216
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   217
I hope you found this tutorial useful.
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   218
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   219
Thank You
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   220
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   221
..
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   222
 * Author : Amit Sethi 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   223
 * First Reviewer : 
a9b71932cbfa Added exercises and slides to getting started with symbolics
Amit Sethi
parents: 418
diff changeset
   224
 * Second Reviewer : Nishanth