summaryrefslogtreecommitdiff
path: root/getting_started_with_files/slides.org
diff options
context:
space:
mode:
Diffstat (limited to 'getting_started_with_files/slides.org')
-rw-r--r--getting_started_with_files/slides.org84
1 files changed, 56 insertions, 28 deletions
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