summaryrefslogtreecommitdiff
path: root/manipulating-strings/slides.org
diff options
context:
space:
mode:
Diffstat (limited to 'manipulating-strings/slides.org')
-rw-r--r--manipulating-strings/slides.org94
1 files changed, 94 insertions, 0 deletions
diff --git a/manipulating-strings/slides.org b/manipulating-strings/slides.org
new file mode 100644
index 0000000..cb8adfd
--- /dev/null
+++ b/manipulating-strings/slides.org
@@ -0,0 +1,94 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Manipulating strings
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Slicing strings to get sub-strings
+ - Reversing strings
+ - Replacing characters in strings.
+ - Converting strings to upper or lower case
+ - Joining a list of strings
+* Question 1
+ Obtain the sub-string excluding the first and last characters from
+ the string ~s~.
+* Solution 1
+ #+begin_src python
+ In []: s[1:-1]
+ #+end_src
+* Question 2
+ Given a list week, week = ~week = ["sun", "mon", "tue", "wed",
+ "thu", "fri", "sat"]~. Check if ~s~ is a valid name of a day of the
+ week. Change the solution to this problem, to include forms like,
+ SAT, SATURDAY, Saturday and Sat.
+* Solution 2
+ #+begin_src python
+ In []: s in week
+ In []: s.lower()[:3] in week
+ #+end_src
+* Question 3
+ Given ~email~ -- ~info@fossee[dot]in~
+
+ Replace the ~[dot]~ with ~.~ in ~email~
+* Solution 3
+ #+begin_src python
+ email.replace('[dot], '.')
+ print email
+ #+end_src
+* Question 4
+ From the ~email_str~ that we generated, change the separator to be a
+ semicolon instead of a comma.
+* Solution 4
+ #+begin_src python
+ email_str = email_str.replace(",", ";")
+ #+end_src
+* Summary
+ You should now be able to --
+ - Slice strings and get sub-strings out of them
+ - Reverse strings
+ - Replace characters in strings.
+ - Convert strings to upper or lower case
+ - Join a list of strings
+
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+