# HG changeset patch # User bhanu # Date 1289930202 -19800 # Node ID 71697b10f4ae8af939428bdb5069a34cc33925c7 # Parent fcb9936eb009f1502b85ae460f21a2768c367584 Language check done for `manipulating strings` diff -r fcb9936eb009 -r 71697b10f4ae getting-started-sagenotebook/script.rst --- a/getting-started-sagenotebook/script.rst Mon Nov 15 16:07:00 2010 +0530 +++ b/getting-started-sagenotebook/script.rst Tue Nov 16 23:26:42 2010 +0530 @@ -25,7 +25,7 @@ Internal Reviewer : Punch External Reviewer : Language Reviewer : Bhanukiran - Checklist OK? : [2010-10-05] + Checklist OK? : <15-11-2010, Anand, OK> [2010-10-05] Script diff -r fcb9936eb009 -r 71697b10f4ae getting-started-strings/script.rst --- a/getting-started-strings/script.rst Mon Nov 15 16:07:00 2010 +0530 +++ b/getting-started-strings/script.rst Tue Nov 16 23:26:42 2010 +0530 @@ -165,7 +165,7 @@ As said earlier, strings are immutable. We cannot manipulate a string. Although there are some methods which let us manipulate -strings. We will look at them in the advanced session on strings. In +strings, we will look at them in the advanced session on strings. In addition to the methods that let us manipulate the strings we have methods like split which lets us break the string on the specified separator, the join method which lets us combine the list of strings diff -r fcb9936eb009 -r 71697b10f4ae manipulating-lists/script.rst --- a/manipulating-lists/script.rst Mon Nov 15 16:07:00 2010 +0530 +++ b/manipulating-lists/script.rst Tue Nov 16 23:26:42 2010 +0530 @@ -11,8 +11,9 @@ .. 3. .. Author : Madhu - Internal Reviewer : + Internal Reviewer : Punch External Reviewer : + Language Reviewer : Bhanukiran Checklist OK? : [2010-10-05] Script @@ -24,10 +25,10 @@ {{{ Show the slide containing the outline }}} -We have already learnt a lot about Lists in Python. In this tutorial, -we will learn more about advanced features of Lists in Python. We will -see how to concatenate two lists, details of slicing and striding of -lists, methods to sort and reverse lists. +We have already learnt about Lists in Python. In this tutorial, +we will learn about more advanced features of Lists in Python like how +to concatenate two lists, details of slicing and striding of lists, +methods to sort and reverse lists. {{{ Shift to terminal and start ipython }}} @@ -49,16 +50,16 @@ primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] -To obtain the all the primes between 10 and 20 from the above list of +To obtain all the primes between 10 and 20 from the above list of primes we say:: primes[4:8] This gives us all the elements in the list starting from the element -with the index 4 which is 11 in our list upto the element with index 8 +with the index 4, which is 11 in our list, upto the element with index 8 in the list but not including the eigth element. So we obtain a slice starting from 11 upto 19th. It is a very important to remember that -when ever we specify a range of elements in Python the start index is +whenever we specify a range of elements in Python the start index is included and end index is not included. So in the above case, 11 which was the element with the index 4 was included but 23 which was the element with index 8 was excluded. @@ -129,7 +130,7 @@ gives us all the multiples of 3 from the list, since every third element in it, starting from 0, is divisible by 3. -The other basic operation that we can perform on list is concatenation +The other basic operation that we can perform on lists is concatenation of two or more lists. We can combine two lists by using the "plus" operator. Say we have @@ -160,7 +161,7 @@ a [1, 5, 6, 7, 7, 10] -Since the sort method sorts the list inplace the original list we had +As the sort method sorts the elements of a list, the original list we had is overwritten or replaced. We have no way to obtain the original list back. One way to avoid this is to keep a copy of the original list in another variable and run the sort method on the list. However Python @@ -174,8 +175,7 @@ sa = sorted(a) -Similarly to perform certain operations on the list we would like to -reverse the list. Python provides reverse method which again reverses +Python also provides the reverse method which reverses the list inplace:: a = [1, 2, 3, 4, 5]