|
1 #+LaTeX_CLASS: beamer |
|
2 #+LaTeX_CLASS_OPTIONS: [presentation] |
|
3 #+BEAMER_FRAME_LEVEL: 1 |
|
4 |
|
5 #+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} |
|
6 #+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra) |
|
7 #+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 |
|
8 |
|
9 #+LaTeX_CLASS: beamer |
|
10 #+LaTeX_CLASS_OPTIONS: [presentation] |
|
11 |
|
12 #+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl} |
|
13 #+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} |
|
14 |
|
15 #+LaTeX_HEADER: \usepackage{listings} |
|
16 |
|
17 #+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries, |
|
18 #+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, |
|
19 #+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries} |
|
20 |
|
21 #+TITLE: Manipulating strings |
|
22 #+AUTHOR: FOSSEE |
|
23 #+EMAIL: |
|
24 #+DATE: |
|
25 |
|
26 #+DESCRIPTION: |
|
27 #+KEYWORDS: |
|
28 #+LANGUAGE: en |
|
29 #+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t |
|
30 #+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc |
|
31 |
|
32 * Outline |
|
33 - Slicing strings to get sub-strings |
|
34 - Reversing strings |
|
35 - Replacing characters in strings. |
|
36 - Converting strings to upper or lower case |
|
37 - Joining a list of strings |
|
38 * Question 1 |
|
39 Obtain the sub-string excluding the first and last characters from |
|
40 the string ~s~. |
|
41 * Solution 1 |
|
42 #+begin_src python |
|
43 In []: s[1:-1] |
|
44 #+end_src |
|
45 * Question 2 |
|
46 Given a list week, week = ~week = ["sun", "mon", "tue", "wed", |
|
47 "thu", "fri", "sat"]~. Check if ~s~ is a valid name of a day of the |
|
48 week. Change the solution to this problem, to include forms like, |
|
49 SAT, SATURDAY, Saturday and Sat. |
|
50 * Solution 2 |
|
51 #+begin_src python |
|
52 In []: s in week |
|
53 In []: s.lower()[:3] in week |
|
54 #+end_src |
|
55 * Question 3 |
|
56 Given ~email~ -- ~info@fossee[dot]in~ |
|
57 |
|
58 Replace the ~[dot]~ with ~.~ in ~email~ |
|
59 * Solution 3 |
|
60 #+begin_src python |
|
61 email.replace('[dot], '.') |
|
62 print email |
|
63 #+end_src |
|
64 * Question 4 |
|
65 From the ~email_str~ that we generated, change the separator to be a |
|
66 semicolon instead of a comma. |
|
67 * Solution 4 |
|
68 #+begin_src python |
|
69 email_str = email_str.replace(",", ";") |
|
70 #+end_src |
|
71 * Summary |
|
72 You should now be able to -- |
|
73 - Slice strings and get sub-strings out of them |
|
74 - Reverse strings |
|
75 - Replace characters in strings. |
|
76 - Convert strings to upper or lower case |
|
77 - Join a list of strings |
|
78 |
|
79 * Thank you! |
|
80 #+begin_latex |
|
81 \begin{block}{} |
|
82 \begin{center} |
|
83 This spoken tutorial has been produced by the |
|
84 \textcolor{blue}{FOSSEE} team, which is funded by the |
|
85 \end{center} |
|
86 \begin{center} |
|
87 \textcolor{blue}{National Mission on Education through \\ |
|
88 Information \& Communication Technology \\ |
|
89 MHRD, Govt. of India}. |
|
90 \end{center} |
|
91 \end{block} |
|
92 #+end_latex |
|
93 |
|
94 |