diff options
-rw-r--r-- | getting-started-with-lists/getting_started_with_lists.rst | 137 | ||||
-rw-r--r-- | getting-started-with-symbolics/quickref.tex (renamed from symbolics/quickref.tex) | 0 | ||||
-rw-r--r-- | getting-started-with-symbolics/script.rst (renamed from symbolics/script.rst) | 0 | ||||
-rw-r--r-- | getting-started-with-symbolics/slides.tex (renamed from symbolics/slides.tex) | 0 | ||||
-rw-r--r-- | manipulating-strings/script.rst | 15 | ||||
-rw-r--r-- | progress.org | 1 | ||||
-rw-r--r-- | statistics/script.rst | 5 |
7 files changed, 15 insertions, 143 deletions
diff --git a/getting-started-with-lists/getting_started_with_lists.rst b/getting-started-with-lists/getting_started_with_lists.rst deleted file mode 100644 index a82de02..0000000 --- a/getting-started-with-lists/getting_started_with_lists.rst +++ /dev/null @@ -1,137 +0,0 @@ -Hello friends and welcome to the tutorial on getting started with -lists. - - {{{ Show the slide containing title }}} - - {{{ Show the slide containing the outline slide }}} - -In this tutorial we will be getting acquainted with a python data -structure called lists. We will learn :: - - * How to create lists - * Structure of lists - * Access list elements - * Append elements to lists - * Deleting elements from lists - -List is a compound data type, it can contain data of other data -types. List is also a sequence data type, all the elements are in -order and there order has a meaning. - -We will first create an empty list with no elements. On your IPython -shell type :: - - empty = [] - type(empty) - - -This is an empty list without any elements. - -* Filled lists - -Lets now define a list, nonempty and fill it with some random elements. - -nonempty = ['spam', 'eggs', 100, 1.234] - -Thus the simplest way of creating a list is typing out a sequence -of comma-separated values (items) between square brackets. -All the list items need not have the same data type. - - - -As we can see lists can contain different kinds of data. In the -previous example 'spam' and 'eggs' are strings and 100 and 1.234 -integer and float. Thus we can put elements of heterogenous types in -lists. Thus list themselves can be one of the element types possible -in lists. Thus lists can also contain other lists. Example :: - - list_in_list=[[4,2,3,4],'and', 1, 2, 3, 4] - -We access list elements using the number of index. The -index begins from 0. So for list nonempty, nonempty[0] gives the -first element, nonempty[1] the second element and so on and -nonempty[3] the last element. :: - - nonempty[0] - nonempty[1] - nonempty[3] - -We can also access the elememts from the end using negative indices :: - - nonempty[-1] - nonempty[-2] - nonempty[-4] - --1 gives the last element which is the 4th element , -2 second to last and -4 gives the fourth -from last element which is first element. - -We can append elements to the end of a list using append command. :: - - nonempty.append('onemore') - nonempty - nonempty.append(6) - nonempty - -As we can see non empty appends 'onemore' and 6 at the end. - - - -Using len function we can check the number of elements in the list -nonempty. In this case it being 6 :: - - len(nonempty) - - - -Just like we can append elements to a list we can also remove them. -There are two ways of doing it. One is by using index. :: - - del(nonempty[1]) - - - -deletes the element at index 1, i.e the second element of the -list, 'eggs'. The other way is removing element by content. Lets say -one wishes to delete 100 from nonempty list the syntax of the command -should be :: - - a.remove(100) - -but what if their were two 100's. To check that lets do a small -experiment. :: - - a.append('spam') - a - a.remove('spam') - a - -If we check a now we will see that the first occurence 'spam' is removed -thus remove removes the first occurence of the element in the sequence -and leaves others untouched. - - -{{{Slide for Summary }}} - - -In this tutorial we came across a sequence data type called lists. :: - - * We learned how to create lists. - * How to access lists. - * Append elements to list. - * Delete Element from list. - * And Checking list length. - - - -{{{ Sponsored by Fossee Slide }}} - -This tutorial was created as a part of FOSSEE project. - -I hope you found this tutorial useful. - -Thank You - - - * Author : Amit Sethi - * First Reviewer : - * Second Reviewer : Nishanth diff --git a/symbolics/quickref.tex b/getting-started-with-symbolics/quickref.tex index b26d168..b26d168 100644 --- a/symbolics/quickref.tex +++ b/getting-started-with-symbolics/quickref.tex diff --git a/symbolics/script.rst b/getting-started-with-symbolics/script.rst index b9014bf..b9014bf 100644 --- a/symbolics/script.rst +++ b/getting-started-with-symbolics/script.rst diff --git a/symbolics/slides.tex b/getting-started-with-symbolics/slides.tex index 4fc3634..4fc3634 100644 --- a/symbolics/slides.tex +++ b/getting-started-with-symbolics/slides.tex diff --git a/manipulating-strings/script.rst b/manipulating-strings/script.rst index 7873575..50d5e32 100644 --- a/manipulating-strings/script.rst +++ b/manipulating-strings/script.rst @@ -17,7 +17,7 @@ .. #. basic datatypes .. Author : Puneeth - Internal Reviewer : + Internal Reviewer : Amit External Reviewer : Checklist OK? : <put date stamp here, if OK> [2010-10-05] @@ -36,6 +36,7 @@ upper to lower case and vice-versa and joining a list of strings. .. #[punch: reversed returns an iterator. should we still teach it?] + We have an ``ipython`` shell open, in which we are going to work, through out this session. @@ -59,7 +60,7 @@ valid name of a day of the week or not. ``s`` could be in any of the forms --- sat, saturday, Sat, Saturday, -SAT, SATURDAY. We shall now be solving the problem only for the forms, +SAT, SATURDAY. For now, shall now be solving the problem only for the forms, sat and saturday. We shall solve it for the other forms, at the end of the tutorial. @@ -69,6 +70,7 @@ So, we need to check if the first three characters of the given string exists in the variable ``week``. As, with any of the string data-types, strings can be sliced into +.. #[Amit: Sequence data type???] sub-strings. To get the first three characters of s, we say, :: @@ -82,7 +84,7 @@ As we already know, the last element of the string can be accessed using ``s[-1]``. Following is an exercise that you must do. - +.. #[Amit: I don't know I am not sure about the sentence formation.] %%1%% Obtain the sub-string excluding the first and last characters from the string s. @@ -127,7 +129,7 @@ So, we obtain the reverse of s, by simply saying, :: s[::-1] - +.. #[amit: I think using reversed in not required after this] Now, to check if the string is ``s`` is palindromic, we say :: @@ -157,6 +159,9 @@ Let's try it out. Note that these methods, do not change the original string, but return a new string. +.. #[amit: I wish we could include this right when s.upper() is used so +.. that it is clear] + Following is an exercise that you must do. %%2%% Check if ``s`` is a valid name of a day of the week. Change the @@ -171,6 +176,8 @@ Please, pause the video here. Do the exercise and then continue. s.lower()[:3] in week +.. #[amit: May be a sentence or two about what our original problem was and +.. how this helps in solving it. One can loose the flow.] We just convert any input string to lower case and then check if it is present in the list ``week``. diff --git a/progress.org b/progress.org index 84e0aa0..b323acd 100644 --- a/progress.org +++ b/progress.org @@ -41,6 +41,7 @@ |---------+----------------------------------------+-------+----------+---------------------------------------+-----------| | 7.1 LO: | manipulating lists | 3 | Madhu | | | | 7.2 LO: | manipulating strings | 2 | Punch | Anoop (Pending) | | +| 7.2 LO: | manipulating strings | 2 | Punch | Anoop (Pending) | | | 7.3 LO: | getting started with tuples | 2 | Nishanth | | | | 7.4 LO: | dictionaries | 2 | Anoop | Pending | | | 7.5 LO: | sets | 2 | Nishanth | | | diff --git a/statistics/script.rst b/statistics/script.rst index 5398e21..5409abf 100644 --- a/statistics/script.rst +++ b/statistics/script.rst @@ -105,7 +105,7 @@ The following are the fields in any given line. * Roll Number 015163 * Name JOSEPH RAJ S * Marks of 5 subjects: ** English 083 ** Hindi 042 ** Maths 47 ** -Science AA (Absent) ** Social 72 +Science 35 ** Social 72 * Total marks 244 * @@ -165,8 +165,9 @@ we have learnt This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India Hope you have enjoyed and found it useful. + Thankyou - + .. Author : Amit Sethi Internal Reviewer 1 : Internal Reviewer 2 : |