diff options
-rw-r--r-- | getting_started_with_files/script.rst | 243 | ||||
-rw-r--r-- | getting_started_with_files/slides.org | 84 | ||||
-rw-r--r-- | getting_started_with_files/slides.tex | 115 | ||||
-rw-r--r-- | getting_started_with_ipython/slides.tex | 7 | ||||
-rw-r--r-- | getting_started_with_strings/script.rst | 293 | ||||
-rw-r--r-- | getting_started_with_strings/slides.org | 88 | ||||
-rw-r--r-- | getting_started_with_strings/slides.tex | 116 | ||||
-rw-r--r-- | template/script.rst | 50 |
8 files changed, 693 insertions, 303 deletions
diff --git a/getting_started_with_files/script.rst b/getting_started_with_files/script.rst index 259be80..22b5ddc 100644 --- a/getting_started_with_files/script.rst +++ b/getting_started_with_files/script.rst @@ -23,166 +23,289 @@ Script ------ -{{{ Show the slide containing title }}} +.. L1 -Hello Friends. Welcome to the tutorial on getting started with files. +{{{ Show the first slide containing title, name of the production +team along with the logo of MHRD }}} -{{{ Show the outline for this tutorial }}} +.. R1 -In this tutorial we shall learn to read files, and do some basic -actions on the file, like opening and reading a file, closing a -file, iterating through the file line-by-line, and appending the -lines of a file to a list. +Hello Friends and Welcome to the tutorial on "Getting started with files". -{{{ switch back to the terminal }}} +.. L2 -As usual, we start IPython, using +{{{ Show slide with objectives }}} + +.. R2 + +At the end of this tutorial, you will be able to, + + 1. Open a file. + #. Read the contents of the file line by line. + #. Read the entire content of file at once. + #. Append the lines of a file to a list. + #. Close the file. + +.. L3 + +{{{ switch to the terminal }}} :: - ipython -pylab + ipython -pylab + +.. R3 + +Open the terminal and start ipython + +.. R4 Let us first open the file, ``pendulum.txt`` present in ``/home/fossee/``. + +.. L4 :: - f = open('/home/fossee/pendulum.txt') + f = open('/home/fossee/pendulum.txt') -``f`` is called a file object. Let us type ``f`` on the terminal to +.. R5 + +Here ``f`` is called a file object. Let us type ``f`` on the terminal to see what it is. + +.. L5 :: - f + f + +.. R6 + +The file object shows the filepath and mode of the file which is open. +'r' stand for read only mode and 'w' stands for write mode. +As you can see, this file is open in read only mode. -The file object shows, the file which is open and the mode (read -or write) in which it is open. Notice that it is open in read only -mode, here. +.. L6 + +.. R7 We shall first learn to read the whole file into a single -variable. We use the ``read`` method of ``f`` to read, all the contents of the file -into the variable ``pend``. +variable. We use the ``read`` method to read all the contents of the file +into the variable, ``pend``. + +.. L7 :: - pend = f.read() + pend = f.read() + +.. R8 -Now, let us see what is in ``pend``, by typing +Now, let us see what ``pend`` contains, by typing ``print pend`` + +.. L8 :: - print pend + print pend + +.. R9 We can see that ``pend`` has all the data of the file. Type just ``pend`` to see more explicitly, what it contains. + +.. L9 :: - pend + pend -Following is an exercise that you must do. +.. L10 -{{ show slide with Question 1 }} +{{{ show slide with Question 1 }}} -%%1%% Split the variable into a list, ``pend_list``, of the lines in -the file. Hint, use the tab command to see what methods the string -variable has. +.. R10 -Please, pause the video here. Do the exercise and then continue. +Pause the video here, try out the following exercise and resume the video. -{{ show slide with Solution 1 }} +Split the variable into a list, ``pend_list``, of the lines in +the file. +.. L11 :: - pend_list = pend.splitlines() + pend_list = pend.splitlines() + pend_list + +.. R11 - pend_list +We use the function ``splitlines`` to solve this problem. + +.. R12 Now, let us learn to read the file line-by-line. But, before that we will have to close the file, since the file has already been read till the end. Let us close the file opened into f. + +.. L12 :: - f.close() + f.close() + +.. R13 -Let us again type ``f`` on the prompt to see what it shows. +Again type ``f`` on the prompt to see what it contains. + +.. L13 :: - f + f + +.. R14 Notice, that it now says the file has been closed. It is a good programming practice to close any file objects that we have opened, after their job is done. -Let us, now move on to reading files line-by-line. +.. L14 + +.. L15 -Following is an exercise that you must do. +{{{ Show slide with Question 2 }}} + +.. R15 + +Let us, now move on to reading files line-by-line. +Pause the video here, try out the following exercise and resume the video. -%%2%% Re-open the file ``pendulum.txt`` with ``f`` as the file object. +Re-open the file ``pendulum.txt`` with ``f`` as the file object. -Please, pause the video here. Do the exercise and then continue. +.. R16 We just use the up arrow until we reach the open command and issue it again. + +.. L16 :: - f = open('/home/fossee/pendulum.txt') + f = open('/home/fossee/pendulum.txt') + +.. R17 Now, to read the file line-by-line, we iterate over the file object line-by-line, using the ``for`` command. Let us iterate over the file line-wise and print each of the lines. + +.. L17 :: - for line in f: - print line + for line in f: + print line + +.. R18 -``line`` is variable, sometimes called the loop +``line`` is a variable, sometimes called the loop variable, and it is not a keyword. We could have used any other variable name, but ``line`` seems meaningful enough. +.. L18 + +.. R19 + Instead of just printing the lines, let us append them to a list, ``line_list``. We first initialize an empty list, ``line_list``. + +.. L19 :: - line_list = [ ] + line_list = [ ] + +.. R20 Let us then read the file line-by-line and then append each of the -lines, to the list. We could, as usual close the file using +lines to the list. We could, as usual close the file using ``f.close`` and re-open it. But, this time, let's leave alone the file object ``f`` and directly open the file within the for statement. This will save us the trouble of closing the file, each time we open it. +.. L20 :: - for line in open('/home/fossee/pendulum.txt'): - line_list.append(line) + for line in open('/home/fossee/pendulum.txt'): + line_list.append(line) + +.. R21 Let us see what ``line_list`` contains. + +.. L21 :: - line_list + line_list + +.. R22 Notice that ``line_list`` is a list of the lines in the file, along with the newline characters. If you noticed, ``pend_list`` did not -contain the newline characters, because the string ``pend`` was +contain the newline characters, because the string ``pend``, was split on the newline characters. -Using some string methods, that we shall look at in the tutorial on -strings, we can strip out the newline characters from the lines. +We can strip out the newline characters from the lines by using some string methods +which we shall look in the further tutorial on strings. + +.. L22 + +.. L23 + +{{{ Show the summary slide }}} -.. #[[Anoop: I think the code that are required to be typed can be - added to the slide.]] +.. R23 -{{{ show the summary slide }}} +This brings us to the end of this tutorial. In this tutorial, we learnt to, + + 1. Open and close files using the ``open`` and ``close`` functions respectively. + #. Read the data in the files as a whole,by using the ``read`` function. + #. Read the data in the files line by line by iterating over the file object using the + ``for`` loop. + #. Append the lines of a file to a list using the ``append`` function within the + ``for`` loop. -That brings us to the end of this tutorial. In this tutorial we -have learnt to open and close files, read the data in the files as -a whole, using the read command or reading it line by line by -iterating over the file object. +.. L24 -{{{ Show the "sponsored by FOSSEE" slide }}} +{{{Show self assessment questions slide}}} -This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India +.. R24 + +Here are some self assessment questions for you to solve + +1. The ``open`` function returns a + + - string + - list + - file object + - function + +2. What does the function ``splitlines()`` do. + + - Displays the data as strings,all in a line + - Displays the data line by line as strings + - Displays the data line by line but not as strings + +.. L25 + +{{{solution of self assessment questions on slide}}} + +.. R25 + +And the answers, + +1. The function ``open``, returns a file object. +2. The function ``splitlines`` displays the data line by line as strings. + +.. L26 + +{{{ Show the Thankyou slide }}} + +.. R26 Hope you have enjoyed and found it useful. Thank you! - diff --git a/getting_started_with_files/slides.org b/getting_started_with_files/slides.org index d9e6428..2321329 100644 --- a/getting_started_with_files/slides.org +++ b/getting_started_with_files/slides.org @@ -18,7 +18,7 @@ #+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, #+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries} -#+TITLE: Getting started with files +#+TITLE: #+AUTHOR: FOSSEE #+EMAIL: #+DATE: @@ -29,43 +29,71 @@ #+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 - - Opening and reading contents of a file - - Closing open files - - Reading all the contents of the file at once - - Reading files line by line +* +#+begin_latex +\begin{center} +\vspace{12pt} +\textcolor{blue}{\huge Getting started with Files} +\end{center} +\vspace{18pt} +\begin{center} +\vspace{10pt} +\includegraphics[scale=0.95]{../images/fossee-logo.png}\\ +\vspace{5pt} +\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\ +\scriptsize Funded by National Mission on Education through ICT\\ +\scriptsize MHRD,Govt. of India\\ +\includegraphics[scale=0.30]{../images/iitb-logo.png}\\ +\end{center} +#+end_latex +* Objectives + At the end of this tutorial, you will be able to, + - Open a file. + - Read the contents of the file line by line. + - Read the entire content of file at once. + - Append the lines of a file to a list. + - Close the file. * Question 1 Split the variable into a list, =pend_list=, of the lines in the - file. Hint, use the tab command to see what methods the string - variable has. -* Solution 1 - #+begin_src python - In []: pend_list = pend.splitlines() - - In []: pend_list - #+end_src + file. * Question 2 Re-open the file =pendulum.txt= with =f= as the file object. -* Solution 2 - #+begin_src python - In []: f = open('/home/fossee/pendulum.txt') - #+end_src * Summary - - Opening a file using =open= function - - Reading all the contents of the file at once using =read()= method - - Closing open files using the =close= method - - Reading files line by line by iterating using a =for= loop -* Thank you! + In this tutorial, we have learnt to – + - Open and close files using the ``open`` and ``close`` functions respectively. + - Read the data in the files as a whole,by using the ``read`` function. + - Read the data in the files line by line by iterating over the file object + using the ``for`` loop. + - Append the lines of a file to a list using the ``append`` function within + the ``for`` loop. +* Evaluation + 1. The ``open`` function returns a + + - string + - list + - file object + - function + + 2. What does the function ``splitlines()`` do. + + - Displays the data as strings,all in a line + - Displays the data line by line as strings + - Displays the data line by line but not as strings +* Solutions + 1. file object + + 2. Displays the data line by line as strings +* #+begin_latex \begin{block}{} \begin{center} - This spoken tutorial has been produced by the - \textcolor{blue}{FOSSEE} team, which is funded by the + \textcolor{blue}{\Large THANK YOU!} \end{center} + \end{block} +\begin{block}{} \begin{center} - \textcolor{blue}{National Mission on Education through \\ - Information \& Communication Technology \\ - MHRD, Govt. of India}. + For more Information, visit our website\\ + \url{http://fossee.in/} \end{center} \end{block} #+end_latex diff --git a/getting_started_with_files/slides.tex b/getting_started_with_files/slides.tex index f3e1765..56582b4 100644 --- a/getting_started_with_files/slides.tex +++ b/getting_started_with_files/slides.tex @@ -1,6 +1,6 @@ -% Created 2010-10-21 Thu 14:35 +% Created 2011-05-18 Wed 12:37 \documentclass[presentation]{beamer} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{fixltx2e} \usepackage{graphicx} @@ -8,7 +8,6 @@ \usepackage{float} \usepackage{wrapfig} \usepackage{soul} -\usepackage{t1enc} \usepackage{textcomp} \usepackage{marvosym} \usepackage{wasysym} @@ -24,14 +23,14 @@ commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, showstringspaces=false, keywordstyle=\color{blue}\bfseries} \providecommand{\alert}[1]{\textbf{#1}} -\title{Getting started with files} +\title{} \author{FOSSEE} \date{} \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} \begin{document} -\maketitle + @@ -42,33 +41,42 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \begin{frame} -\frametitle{Outline} -\label{sec-1} -\begin{itemize} -\item Opening and reading contents of a file -\item Closing open files -\item Reading all the contents of the file at once -\item Reading files line by line -\end{itemize} +\begin{center} +\vspace{12pt} +\textcolor{blue}{\huge Getting started with Files} +\end{center} +\vspace{18pt} +\begin{center} +\vspace{10pt} +\includegraphics[scale=0.95]{../images/fossee-logo.png}\\ +\vspace{5pt} +\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\ +\scriptsize Funded by National Mission on Education through ICT\\ +\scriptsize MHRD,Govt. of India\\ +\includegraphics[scale=0.30]{../images/iitb-logo.png}\\ +\end{center} \end{frame} \begin{frame} -\frametitle{Question 1} +\frametitle{Objectives} \label{sec-2} - Split the variable into a list, \texttt{pend\_list}, of the lines in the - file. Hint, use the tab command to see what methods the string - variable has. + At the end of this tutorial, you will be able to, + +\begin{itemize} +\item Open a file. +\item Read the contents of the file line by line. +\item Read the entire content of file at once. +\item Append the lines of a file to a list. +\item Close the file. +\end{itemize} \end{frame} -\begin{frame}[fragile] -\frametitle{Solution 1} +\begin{frame} +\frametitle{Question 1} \label{sec-3} -\begin{verbatim} -In []: pend_list = pend.splitlines() - -In []: pend_list -\end{verbatim} + Split the variable into a list, \texttt{pend\_list}, of the lines in the + file. \end{frame} \begin{frame} \frametitle{Question 2} @@ -76,40 +84,65 @@ In []: pend_list Re-open the file \texttt{pendulum.txt} with \texttt{f} as the file object. \end{frame} -\begin{frame}[fragile] -\frametitle{Solution 2} +\begin{frame} +\frametitle{Summary} \label{sec-5} -\begin{verbatim} -In []: f = open('/home/fossee/pendulum.txt') -\end{verbatim} + In this tutorial, we have learnt to – + +\begin{itemize} +\item Open and close files using the ``open`` and ``close`` functions respectively. +\item Read the data in the files as a whole,by using the ``read`` function. +\item Read the data in the files line by line by iterating over the file object + using the ``for`` loop. +\item Append the lines of a file to a list using the ``append`` function within + the ``for`` loop. +\end{itemize} \end{frame} \begin{frame} -\frametitle{Summary} +\frametitle{Evaluation} \label{sec-6} + +\begin{enumerate} +\item The ``open`` function returns a \begin{itemize} -\item Opening a file using \texttt{open} function -\item Reading all the contents of the file at once using \texttt{read()} method -\item Closing open files using the \texttt{close} method -\item Reading files line by line by iterating using a \texttt{for} loop +\item string +\item list +\item file object +\item function \end{itemize} +\item What does the function ``splitlines()`` do. +\begin{itemize} +\item Displays the data as strings,all in a line +\item Displays the data line by line as strings +\item Displays the data line by line but not as strings +\end{itemize} +\end{enumerate} \end{frame} \begin{frame} -\frametitle{Thank you!} +\frametitle{Solutions} \label{sec-7} + +\begin{enumerate} +\item file object +\item Displays the data line by line as strings +\end{enumerate} +\end{frame} +\begin{frame} + \begin{block}{} \begin{center} - This spoken tutorial has been produced by the - \textcolor{blue}{FOSSEE} team, which is funded by the + \textcolor{blue}{\Large THANK YOU!} \end{center} + \end{block} +\begin{block}{} \begin{center} - \textcolor{blue}{National Mission on Education through \\ - Information \& Communication Technology \\ - MHRD, Govt. of India}. + For more Information, visit our website\\ + \url{http://fossee.in/} \end{center} \end{block} \end{frame} -\end{document} +\end{document}
\ No newline at end of file diff --git a/getting_started_with_ipython/slides.tex b/getting_started_with_ipython/slides.tex index ad3d55a..e3bd26a 100644 --- a/getting_started_with_ipython/slides.tex +++ b/getting_started_with_ipython/slides.tex @@ -1,4 +1,4 @@ -% Created 2011-05-18 Wed 10:36 +% Created 2011-05-18 Wed 11:53 \documentclass[presentation]{beamer} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} @@ -142,9 +142,8 @@ round(2.484, 2) \label{sec-9} + \begin{enumerate} -\item Ipython is a programming similar to Python? - True or False \item Which key combination quits ``ipython``? \begin{itemize} \item Ctrl + C @@ -166,9 +165,9 @@ round(2.484, 2) \frametitle{Solutions} \label{sec-10} + \begin{enumerate} -\item False \item Ctrl + D \item question mark (?) \end{enumerate} diff --git a/getting_started_with_strings/script.rst b/getting_started_with_strings/script.rst index 754fede..d383dcb 100644 --- a/getting_started_with_strings/script.rst +++ b/getting_started_with_strings/script.rst @@ -24,144 +24,242 @@ Script ------ -{{{ Show the slide containing the title }}} +.. L1 -Hello friends. Welcome to this spoken tutorial on Getting started with -strings. +{{{ Show the first slide containing title, name of the production +team along with the logo of MHRD }}} -{{{ Show the slide containing the outline }}} +.. R1 -In this tutorial, we will look at what we really mean by strings, how -Python supports the use of strings and some of the operations that can -be performed on strings. +Hello friends and Welcome to the tutorial on "Getting started with +strings". + +.. L2 + +{{{ Show slide with objectives }}} + +.. R2 + +At the end of this tutorial, you will be able to, + + 1. Define strings in differnt ways. + #. Concatenate strings. + #. Print a string repeatedly. + #. Access individual elements of the string. + #. Learn immutability of strings. + +.. L3 {{{ Shift to terminal and start ipython }}} +:: -To begin with let us start ipython, by typing:: + ipython - ipython +.. R3 -on the terminal +Open the terminal and invoke the ipython interpreter by typing ipython + +.. R4 So, what are strings? In Python anything within either single quotes or double quotes or triple single quotes or triple double quotes are strings. -{{{ Type in ipython the following and read them as you type }}}:: +.. L4 + +{{{ Type in ipython the following and read them as you type }}} +:: + + 'This is a string' + "This is a string too" + '''This is a string as well''' + """This is also a string""" + 'p' + "" - 'This is a string' - "This is a string too' - '''This is a string as well''' - """This is also a string""" - 'p' - "" +.. R5 Note that it really doesn't matter how many characters are present in the string. The last example is a null string or an empty string. Having more than one control character to define strings is handy when -one of the control characters itself is part of the string. For -example:: +one of the control characters itself is part of the string. For example + +.. L5 + +:: - "Python's string manipulation functions are very useful" + "Python's string manipulation functions are very useful" + +.. R6 By having multiple control characters, we avoid the need for escaping characters -- in this case the apostrophe. -The triple quoted strings let us define multi-line strings without +Let us now move on to the triple quoted strings. Let us define multi-line strings without using any escaping. Everything within the triple quotes is a single -string no matter how many lines it extends:: +string no matter how many lines it extends + +.. L6 +:: + + """Having more than one control character to define + strings come as very handy when one of the control + characters itself is part of the string.""" - """Having more than one control character to define - strings come as very handy when one of the control - characters itself is part of the string.""" +.. R7 -We can assign this string to any variable:: +We can assign this string to any variable - a = 'Hello, World!' +.. L7 +:: + + a = 'Hello, World!' + +.. R8 Now 'a' is a string variable. String is a collection of characters. In -addition string is an immutable collection. So all the operations that -are applicable to any other immutable collection in Python works on -string as well. So we can add two strings:: +addition string is an immutable collection which means that the string cannot be modified +after it is created.So all the operations that are applicable to any other immutable +collection in Python, works on strings as well. Hence we can add two strings + +.. L8 +:: - a = 'Hello' - b = 'World' - c = a + ', ' + b + '!' + a = 'Hello' + b = 'World' + c = a + ', ' + b + '!' + print c + +.. R9 We can add string variables as well as the strings themselves all in the same statement. The addition operation performs the concatenation of two strings. -Similarly we can multiply a string with an integer:: +.. L9 + +.. R10 + +Similarly we can multiply a string with an integer + +.. L10 +:: + + a = 'Hello' + a * 5 - a = 'Hello' - a * 5 +.. R11 -gives another string in which the original string 'Hello' is repeated +It gives another string in which the original string 'Hello' is repeated 5 times. -Following is an exercise that you must do. +.. L11 + +.. L12 + +{{{ Show slide with Question 1 }}} + +.. R12 -%% %% Obtain the string ``%% -------------------- %%`` (20 hyphens) - without typing out all the twenty hyphens. +Pause the video here, try out the following exercise and resume the video. -Please, pause the video here. Do the exercise and then continue. + Obtain the string ``%% -------------------- %%`` (20 hyphens) + without typing out all the twenty hyphens. + +.. L13 + +{{{ Switch to terminal }}} :: - s = "%% " + "-"*20 + " %%" + s = "%% " + "-"*20 + " %%" + print s + +.. R13 Let's now look at accessing individual elements of strings. Since, -strings are collections we can access individual items in the string -using the subscripts:: +strings are collections, we can access individual items in the string +using the subscripts - a[0] +.. L14 +:: -gives us the first character in the string. The indexing starts from 0 -for the first character and goes up to n-1 for the last character. We -can access the strings from the end using negative indices:: + a[0] - a[-1] +.. R14 -gives us the last element of the string and +a[0] gives us the first character in the string. The indexing starts from 0 +for the first character and goes up to (n-1) for the last character,where 'n' is the total +number of characters in a string. +We can access the strings from the end using negative indices + +.. L15 :: + a[-1] a[-2] -gives us second element from the end of the string +.. R15 + +a[-1] gives us the last element of the string and +a[-2] gives us second element from the end of the string. + +.. L16 + +{{{ Show slide with Question 2 }}} + +.. R16 -Following is an exercise that you must do. +Pause the video here, try out the following exercise and resume the video. -%% %% Given a string, ``s = "Hello World"``, what is the output of:: +Given a string, ``s = "Hello World"``, what is the output of:: - s[-5] - s[-10] - s[-15] + s[-5] + s[-10] + s[-15] -Please, pause the video here. Do the exercise and then continue. +.. L17 +{{{ Switch to terminal }}} :: - s[-5] + s[-5] -gives us 'W' +.. R17 + +s[-5] gives us 'W' + +.. L18 :: - s[-10] + s[-10] + +.. R18 + +s[-10] gives us 'e' and -gives us 'e' and +.. L19 :: - s[-15] + s[-15] -gives us an ``IndexError``, as should be expected, since the string +.. R19 + +s[-15] gives us an ``IndexError``, as should be expected, since the string given to us is only 11 characters long. -Let us attempt to change one of the characters in a string:: +.. R20 + +Let us attempt to change one of the characters in a string + +.. L20 +:: + + a = 'hello' + a[0] = 'H' - a = 'hello' - a[0] = 'H' +.. R21 As said earlier, strings are immutable. We cannot manipulate a string. Although there are some methods which let us manipulate @@ -171,20 +269,65 @@ methods like split which lets us break the string on the specified separator, the join method which lets us combine the list of strings into a single string based on the specified separator. +.. L21 + +.. L22 + {{{ Show summary slide }}} -This brings us to the end of another session. In this tutorial session -we learnt +.. R22 + +Let's revise quickly what we have learnt today.In this tutorial we have learnt to, + + 1. Define strings in differnt ways. + #. Concatenate strings by performing addition. + #. Repeat a string 'n' number of times by doing multiplication. + #. Access individual elements of the string by using their subscripts. + #. Use the concept of immutability of strings. + +.. L23 + +{{{Show self assessment questions slide}}} + +.. R23 + +Here are some self assessment questions for you to solve + +1. Write code to assign s, the string ``' is called the apostrophe`` + +2. Given strings s and t, ``s = "Hello"`` and ``t = "World"`` and an + integer r, ``r = 2``. What is the output of s * r + s * t? + +3. How will you change s='hello' to s='Hello'. + + - s[0]= H + - s[0]='H' + - strings are immutable,hence cannot be manipulated + +.. L24 + +{{{ solution of self assessment questions on slide }}} + +.. R24 + +And the answers, + +1. The given string can be assigned in this manner +:: + + s = "` is called the apostrophe" + +2. The operation ``s * r + s * t`` will print each of the two words twice + + HelloHelloWorldWorld + +3. Strings are immutable.Therefore they cannot be manipulated. - * How to define strings - * Different ways of defining a string - * String concatenation and repetition - * Accessing individual elements of the string - * Immutability of strings +.. L25 -{{{ Show the "sponsored by FOSSEE" slide }}} +{{{ Show the Thankyou slide }}} -This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India +.. R25 Hope you have enjoyed and found it useful. Thank you! diff --git a/getting_started_with_strings/slides.org b/getting_started_with_strings/slides.org index a1df437..cd95474 100644 --- a/getting_started_with_strings/slides.org +++ b/getting_started_with_strings/slides.org @@ -29,18 +29,33 @@ #+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 -*** Defining strings -*** Concatenation -*** Accessing individual elements -*** Immutability of strings +* + #+begin_latex +\begin{center} +\vspace{12pt} +\textcolor{blue}{\huge Getting started with Strings} +\end{center} +\vspace{18pt} +\begin{center} +\vspace{10pt} +\includegraphics[scale=0.95]{../images/fossee-logo.png}\\ +\vspace{5pt} +\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\ +\scriptsize Funded by National Mission on Education through ICT\\ +\scriptsize MHRD,Govt. of India\\ +\includegraphics[scale=0.30]{../images/iitb-logo.png}\\ +\end{center} +#+end_latex +* Objectives + At the end of this tutorial, you will be able to, + - Define strings in differnt ways. + - Concatenate strings. + - Print a string repeatedly. + - Access individual elements of the string. + - Learn immutability of strings. * Question 1 Obtain the string ~%% -------------------- %%~ (20 hyphens) without typing out all the twenty hyphens. -* Solution 1 - #+begin_src python - s = "%% " + "-"*20 + " %%" - #+end_src * Question 2 Given a string, ~s~ which is ~Hello World~ , what is the output of:: #+begin_src python @@ -48,33 +63,44 @@ s[-10] s[-15] #+end_src -* Solution 2 - #+begin_src python - 'W' - 'e' - IndexError - #+end_src * Summary - In this tutorial we have learnt - + How to define strings - + Different ways of defining a string - + String concatenation and repetition - + Accessing individual elements of the string - + Immutability of strings - -* Thank you! -#+begin_latex + In this tutorial, we have learnt, + - To define strings in differnt ways. + - To concatenate strings by performing addition. + - To repeat a string 'n' number of times by doing multiplication. + - To access individual elements of the string by using their subscripts. + - Use the concept of immutability of strings. + +* Evaluation + 1. Write code to assign s, the string ``' is called the apostrophe`` + + 2. Given strings s and t, ``s = "Hello"`` and ``t = "World"`` and an + integer r, ``r = 2``. What is the output of s * r + s * t? + + 3. How will you change s='hello' to s='Hello'. + + - s[ 0 ]= H + - s[ 0 ]='H' + - strings are immutable,hence cannot be manipulated. +* Solutions + 1. s = "` is called the apostrophe" + + 2. HelloHelloWorldWorld + + 3. Strings are immutable,hence cannot be manipulated. + +* + #+begin_latex \begin{block}{} \begin{center} - This spoken tutorial has been produced by the - \textcolor{blue}{FOSSEE} team, which is funded by the + \textcolor{blue}{\Large THANK YOU!} \end{center} + \end{block} +\begin{block}{} \begin{center} - \textcolor{blue}{National Mission on Education through \\ - Information \& Communication Technology \\ - MHRD, Govt. of India}. + For more Information, visit our website\\ + \url{http://fossee.in/} \end{center} \end{block} #+end_latex - - + diff --git a/getting_started_with_strings/slides.tex b/getting_started_with_strings/slides.tex index ed0dedb..e38ca13 100644 --- a/getting_started_with_strings/slides.tex +++ b/getting_started_with_strings/slides.tex @@ -1,4 +1,4 @@ -% Created 2010-11-10 Wed 10:46 +% Created 2011-05-16 Mon 12:57 \documentclass[presentation]{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -41,41 +41,48 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \begin{frame} -\frametitle{Outline} -\label{sec-1} -\begin{itemize} -\item Defining strings\\ -\label{sec-1_1}% -\item Concatenation\\ -\label{sec-1_2}% -\item Accessing individual elements\\ -\label{sec-1_3}% -\item Immutability of strings\\ -\label{sec-1_4}% -\end{itemize} % ends low level +\begin{center} +\vspace{12pt} +\textcolor{blue}{\huge Getting started with Strings} +\end{center} +\vspace{18pt} +\begin{center} +\vspace{10pt} +\includegraphics[scale=0.95]{../images/fossee-logo.png}\\ +\vspace{5pt} +\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\ +\scriptsize Funded by National Mission on Education through ICT\\ +\scriptsize MHRD,Govt. of India\\ +\includegraphics[scale=0.30]{../images/iitb-logo.png}\\ +\end{center} \end{frame} \begin{frame} -\frametitle{Question 1} +\frametitle{Objectives} \label{sec-2} - Obtain the string \texttt{\%\% -------------------- \%\%} (20 hyphens) without - typing out all the twenty hyphens. + At the end of this tutorial, you will be able to, + +\begin{itemize} +\item Define strings in differnt ways. +\item Concatenate strings. +\item Print a string repeatedly. +\item Access individual elements of the string. +\item Learn immutability of strings. +\end{itemize} \end{frame} -\begin{frame}[fragile] -\frametitle{Solution 1} +\begin{frame} +\frametitle{Question 1} \label{sec-3} -\lstset{language=Python} -\begin{lstlisting} -s = "%% " + "-"*20 + " %%" -\end{lstlisting} + Obtain the string \verb~%% -------------------- %%~ (20 hyphens) without + typing out all the twenty hyphens. \end{frame} \begin{frame}[fragile] \frametitle{Question 2} \label{sec-4} - Given a string, \texttt{s} which is \texttt{Hello World} , what is the output of:: + Given a string, \verb~s~ which is \verb~Hello World~ , what is the output of:: \lstset{language=Python} \begin{lstlisting} s[-5] @@ -83,47 +90,62 @@ s[-10] s[-15] \end{lstlisting} \end{frame} -\begin{frame}[fragile] -\frametitle{Solution 2} +\begin{frame} +\frametitle{Summary} \label{sec-5} -\lstset{language=Python} -\begin{lstlisting} -'W' -'e' -IndexError -\end{lstlisting} + In this tutorial, we have learnt, + +\begin{itemize} +\item To define strings in differnt ways. +\item To concatenate strings by performing addition. +\item To repeat a string `n' number of times by doing multiplication. +\item To access individual elements of the string by using their subscripts. +\item About the immutability of strings. +\end{itemize} \end{frame} \begin{frame} -\frametitle{Summary} +\frametitle{Evaluation} \label{sec-6} - In this tutorial we have learnt + +\begin{enumerate} +\item Write code to assign s, the string ``' is called the apostrophe`` +\item Given strings s and t, ``s = ``Hello''`` and ``t = ``World''`` and an + integer r, ``r = 2``. What is the output of s * r + s * t? +\item How will you change s='hello' to s='Hello'. \begin{itemize} -\item How to define strings -\item Different ways of defining a string -\item String concatenation and repetition -\item Accessing individual elements of the string -\item Immutability of strings +\item s[ 0 ]= H +\item s[ 0 ]='H' +\item strings are immutable,hence cannot be manipulated. \end{itemize} - - +\end{enumerate} \end{frame} \begin{frame} -\frametitle{Thank you!} +\frametitle{Solutions} \label{sec-7} + +\begin{enumerate} +\item s = ``` is called the apostrophe'' +\item HelloHelloWorldWorld +\item Strings are immutable,hence cannot be manipulated. +\end{enumerate} +\end{frame} +\begin{frame} + \begin{block}{} \begin{center} - This spoken tutorial has been produced by the - \textcolor{blue}{FOSSEE} team, which is funded by the + \textcolor{blue}{\Large THANK YOU!} \end{center} + \end{block} +\begin{block}{} \begin{center} - \textcolor{blue}{National Mission on Education through \\ - Information \& Communication Technology \\ - MHRD, Govt. of India}. + For more Information, visit our website\\ + \url{http://fossee.in/} \end{center} \end{block} + \end{frame} -\end{document} +\end{document}
\ No newline at end of file diff --git a/template/script.rst b/template/script.rst index a09cca8..6988d24 100644 --- a/template/script.rst +++ b/template/script.rst @@ -18,35 +18,51 @@ Script ------ -{{{ Show the slide containing title }}} +{{{ Show the first slide containing title, name of the production +team along with the logo of MHRD }}} +Hello Friends. Welcome to the tutorial on (topic of the tutorial) -Hello Friends. Welcome to the tutorial on so-and-so (topic of the tutorial) -{{{ Show the outline slide }}} +{{{ show the objective slide }}} - ... -Following is an (are) exercise(s) that you must do. -%% %% Exercises go here. +Small chunk of content/concept is explained.{clear and concise} -%% %% another exercise -%% %% yet another exercise -Please, pause the video here. Do the exercise(s) and then continue. +{{{Show Exercise 1 slide}}} +Pause the video here, try out the following exercise and resume the video. + +{{{Solution of Exercise 1 either on terminal or slide}}} + + + +Small chunk of content/concept is explained.{clear and concise} + + + +{{{Show Exercise 2 slide}}} +Pause the video here, try out the following exercise and resume the video. + +{{{Solution of Exercise 2 either on terminal or slide}}} + + + +{{{continue the same format ....}}} + + {{{ Show summary slide }}} +This brings us to the end of the tutorial.In this tutorial,we have learnt to, + + -This brings us to the end of the tutorial. -we have learnt +{{{Show the self assessment questions slide}}} +{{{show the solution of self assessment questions.}}} - * - * -{{{ Show the "sponsored by FOSSEE" slide }}} -This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India +{{{ Show the "thank you” slide}}} +Hope you have enjoyed and found it useful. Thank you! -Hope you have enjoyed and found it useful. -Thank you! |