diff options
author | Amit Sethi | 2010-10-26 16:04:50 +0530 |
---|---|---|
committer | Amit Sethi | 2010-10-26 16:04:50 +0530 |
commit | bca2280d4b9f140fb627bedf5b0cec996274bb9e (patch) | |
tree | 2da6668a14408a8c474d194c12f7479559a75d22 | |
parent | 07bf3e2c3142b4a973c11753ec08397bd2b63016 (diff) | |
download | st-scripts-bca2280d4b9f140fb627bedf5b0cec996274bb9e.tar.gz st-scripts-bca2280d4b9f140fb627bedf5b0cec996274bb9e.tar.bz2 st-scripts-bca2280d4b9f140fb627bedf5b0cec996274bb9e.zip |
Reviewed manipulating strings
-rw-r--r-- | manipulating-strings/script.rst | 15 | ||||
-rw-r--r-- | progress.org | 2 |
2 files changed, 12 insertions, 5 deletions
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 77573e4..806a080 100644 --- a/progress.org +++ b/progress.org @@ -40,7 +40,7 @@ | 6.5 LO: | Assessment | 3 | Anoop | | | |---------+----------------------------------------+-------+----------+---------------------------------------+-----------| | 7.1 LO: | manipulating lists | 3 | Madhu | | | -| 7.2 LO: | manipulating strings | 2 | Punch | Pending | | +| 7.2 LO: | manipulating strings | 2 | Punch | Amit | | | 7.3 LO: | getting started with tuples | 2 | Nishanth | | | | 7.4 LO: | dictionaries | 2 | Anoop | Pending | | | 7.5 LO: | sets | 2 | Nishanth | | | |