Python Virtual Training For Arcesium - Module II

Oct 11-15, 2021 Vikrant Patil

These notes are available online at https://notes.pipal.in/2021/arcesium_finop_batch2/

© Pipal Academy LLP

Day 1 | Day 2

We will be using jupyter hub from https://lab2.pipal.in for this training.

create a notebook with name module2-day2

Example - two dimensional list comprehension

Reading Text Files

I have created a subfolder 'test' in current directory, inside that created a test.txt

Example -- implement unix command cat!

cat is unix command which takes filename as argument and prints contets of it on screen

problems

!python3 head.py 4 zen.txt
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
>>> csvparse("tables.csv")
[[1,2,3,4,5,6,7,8,9,10],
 [2,4,8,10,12,14,16,18,20],
 [3,6,9,12,15,18,21,24,27,30]]

Writing text files

mode   meaing
w      Write in text mode. Create new file if does not exist. overwrite if exists
a      Write in text mode, do not overwrite, just append to end.

String formatting