equal
deleted
inserted
replaced
1 ======== |
1 .. Objectives |
2 Script |
2 .. ---------- |
3 ======== |
3 |
4 |
4 .. By the end of this tutorial, you will be able to |
5 {{{ show the welcome slide }}} |
5 |
6 |
6 .. 1. Slice strings and get sub-strings out of them |
7 Welcome to this tutorial on manipulating strings. |
7 .. #. Reverse strings |
|
8 .. #. Replace characters in strings. |
|
9 .. #. Convert to strings to upper or lower case |
|
10 |
|
11 .. Prerequisites |
|
12 .. ------------- |
|
13 |
|
14 .. 1. getting started with strings |
|
15 .. #. getting started with lists |
|
16 .. #. |
|
17 |
|
18 .. Author : Puneeth |
|
19 Internal Reviewer : |
|
20 External Reviewer : |
|
21 Checklist OK? : <put date stamp here, if OK> [2010-10-05] |
|
22 |
|
23 Script |
|
24 ------ |
|
25 |
|
26 {{{ Show the slide containing title }}} |
|
27 |
|
28 Hello Friends. Welcome to this tutorial on manipulating strings. |
8 |
29 |
9 {{{ show the slide with outline }}} |
30 {{{ show the slide with outline }}} |
10 |
31 |
11 In this tutorial we shall learn to manipulate strings, specifically |
32 In this tutorial we shall learn to manipulate strings, specifically |
12 slicing and reversing them, or replacing characters, converting from |
33 slicing and reversing them, or replacing characters, converting from |
57 not included. |
78 not included. |
58 |
79 |
59 As we already know, the last element of the string can be accessed |
80 As we already know, the last element of the string can be accessed |
60 using ``s[-1]``. |
81 using ``s[-1]``. |
61 |
82 |
62 %%1%% Pause the video here and obtain the sub-string excluding the |
83 Following is an exercise that you must do. |
63 first and last characters from the string. |
84 |
|
85 %%1%% Obtain the sub-string excluding the first and last characters |
|
86 from the string. |
|
87 |
|
88 Please, pause the video here. Do the exercise(s) and then continue. |
64 |
89 |
65 :: |
90 :: |
66 |
91 |
67 s[1:-1] |
92 s[1:-1] |
68 |
93 |
129 s.lower() == s.lower()[::-1] |
154 s.lower() == s.lower()[::-1] |
130 |
155 |
131 Note that these methods, do not change the original string, but return |
156 Note that these methods, do not change the original string, but return |
132 a new string. |
157 a new string. |
133 |
158 |
134 a%% %% Pause the video here, and finish the problem of checking if |
159 Following is an exercise that you must do. |
135 ``s`` is a valid name of a day of the week and then resume the |
160 |
136 video. Change the solution to this problem, to include forms like, |
161 %%2%% Check if ``s`` is a valid name of a day of the week. Change the |
137 SAT, SATURDAY, Saturday and Sat. |
162 solution to this problem, to include forms like, SAT, SATURDAY, |
|
163 Saturday and Sat. |
|
164 |
|
165 Please, pause the video here. Do the exercise and then continue. |
138 |
166 |
139 :: |
167 :: |
140 |
168 |
141 s.lower()[:3] in week |
169 s.lower()[:3] in week |
142 |
170 |
158 :: |
186 :: |
159 |
187 |
160 email = email.replace("[at]", "@") |
188 email = email.replace("[at]", "@") |
161 print email |
189 print email |
162 |
190 |
163 %%1%% Pause the video here and replace the ``[dot]`` with ``.`` and then |
191 Following is an exercise that you must do. |
164 resume the video. |
192 |
|
193 %%3%% Replace the ``[dot]`` with ``.`` |
|
194 |
|
195 Please, pause the video here. Do the exercise and then continue. |
165 |
196 |
166 :: |
197 :: |
167 |
198 |
168 email = email.replace("[dot]", ".") |
199 email = email.replace("[dot]", ".") |
169 print email |
200 print email |
174 {{{ show summary slide }}} |
205 {{{ show summary slide }}} |
175 |
206 |
176 In this tutorial, we have learnt how to get substrings, reverse |
207 In this tutorial, we have learnt how to get substrings, reverse |
177 strings and a few useful methods, namely upper, lower and replace. |
208 strings and a few useful methods, namely upper, lower and replace. |
178 |
209 |
179 Thank You! |
210 {{{ Show the "sponsored by FOSSEE" slide }}} |
|
211 |
|
212 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India |
|
213 |
|
214 Hope you have enjoyed and found it useful. |
|
215 Thank you! |
|
216 |