summaryrefslogtreecommitdiff
path: root/manipulating_lists/slides.org
diff options
context:
space:
mode:
Diffstat (limited to 'manipulating_lists/slides.org')
-rw-r--r--manipulating_lists/slides.org92
1 files changed, 57 insertions, 35 deletions
diff --git a/manipulating_lists/slides.org b/manipulating_lists/slides.org
index c0eea62..090e96d 100644
--- a/manipulating_lists/slides.org
+++ b/manipulating_lists/slides.org
@@ -18,7 +18,7 @@
#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
-#+TITLE: Manipulating Lists
+#+TITLE:
#+AUTHOR: FOSSEE
#+EMAIL:
#+DATE:
@@ -30,63 +30,85 @@
#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
#+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
-* Outline
- In this session we shall be looking at
- - Concatenating lists
- - Obtaining parts of lists
- - Sorting lists
- - Reversing lists
-* Question 1
- Obtain the primes less than 10, from the list ~primes~.
-* Solution 1
- #+begin_src python
- primes[0:4]
- #+end_src python
+*
+#+begin_latex
+\begin{center}
+\vspace{12pt}
+\textcolor{blue}{\huge Manipulating Lists}
+\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,
+
+ - Concatenate two lists.
+ - Learn the details of slicing and striding of lists.
+ - Sort and reverse lists.
+* Pre-requisite
+Spoken tutorial on -
+- Getting started with Lists.
+* Exercise 1
+ Obtain the primes less than 10, from the list ~primes~.
* Slicing
#+begin_src python
p[start:stop]
#+end_src python
- Returns all elements of ~p~ between ~start~ and ~stop~
- The element with index equal to ~stop~ is *not* included.
-* Question 2
+* Exercise 2
Obtain all the multiples of three from the list ~num~.
* Solution 2
#+begin_src python
num[::3]
#+end_src python
-* Question 3
+* Exercise 3
Given a list of marks of students in an examination, obtain a list
with marks in descending order.
#+begin_src python
marks = [99, 67, 47, 100, 50, 75, 62]
#+end_src python
-* Solution 3
- #+begin_src python
- sorted(marks)[::-1]
- #+end_src python
-OR
- #+begin_src python
- sorted(marks, reverse=True)
- #+end_src python
-
* Summary
- In this tutorial session we learnt
- + Obtaining parts of lists using slicing and striding
- + List concatenation
- + Sorting lists
- + Reversing lists
+ In this tutorial, we have learnt to,
+
+ - Obtain parts of lists using slicing and striding.
+ - Concatenate lists using the ``plus'' operator.
+ - Sort lists using the ``sort'' method.
+ - Use the method ``reverse'' to reverse the lists.
+
+* Evaluation
+1. Given the list primes, primes = [2, 3, 5, 7, 11, 13, 17, 19, 23,
+ 29], How do you obtain the last 4 primes?
-* Thank you!
+2. Given a list, p, of unknown length, obtain the first 3 (or all, if
+ there are fewer) characters of it.
+
+3. ``reversed'' function reverses a list in place. True or False?
+* Solutions
+1. primes[-4:]
+
+2. p[:3]
+
+3. False
+*
#+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