Python in 4 sittings: Sitting 3

Introduction to Python

Summary of the third class

26th June, 2021

© pi4py.netlify.app

feel free to contact us;

arabindo@protonmail.com

kaustavbasu97@gmail.com

We can run bash command here, in the Jupyter notebook followed by a !

for example to list the files and dir in the current path one need to run the !ls

To access files from from python, one can place the file in current directrory. The problem arises when the file is in another folder in that directory. For that one can use os library

In the session2 notebook, we counted words from some text.(in[5] of session2_fresh.ipynb file). demo.txt file contain that same text. Now we will read that file with python and count the words again

we've used f.readline() method. Try to run f.readlines() indepedently. Observe the output.

Let's make a simple password locker.

The original idea is taken from

Automate the boring stuff with Python - Al Sweigart

Checkout the locker.py file for command line argument approach

Introduction to NumPy

We have shown Pandas just to read csv and excel files

I'm showing here for csv files. The method is similar for xls files.

You must be careful with xlsx files(earlier excel file extension)

Before we close, we will do some matplotlib stuff

We can set label of the plots,

ranges for x-axis and y-axis,

can set title,

and many more.

Just google it.

Or visit Official documentation

https://matplotlib.org/stable/contents.html

Not need to read everything.

Just learn what is needed!

Otherwise it is just huge!

The only way to learn a library efficiently, is to read official documentation

So I'm leaving those as a reading project for you!

Here you can also have some label for the colours and amplitude relation. Again, you know :p

Google it!

That's it for today! Proble set will be live soon!