Posts

Showing posts from June, 2016

Access clipboard using python

Image
I'm doing this tutorial using Python 3.x, but the same can be done using Python 2.x



The following python script has following properties

 requires pyperclip module to run  Copy to and from clipboard  Tested on Unix(MacOs and Ubuntu)  But should also work on windows  Try, test, run and then write your own  And I forgot something, Hello everyone  :-) The required pyperclip can be installed as follows:

pip3 install pyperclip or more specifically
python3 -m pip install pyperclip
The installation can checked on Unix in following way:
pip3 freeze|grep 'pyperclip' or more specifically
python3 -m pip freeze|grep 'pyperclip'
The result will be something like:
pyperclip==1.5.27

Playing with birthday using Python

Image
I always wondered how to access calendar and work with dates in programming languages,
Thanks to Python'sdatetime module, which makes it so easy to work with it.



The following python script has following properties

requires python 3.x to run Read birthdate and tell birth month, tell number of days till next birthday Tested on Unix(MacOs and Ubuntu) But should also work on windows Try, test, run and then write your own And I forgot something, Hello everyone  :-)


Further you can use this idea to read a birthday and add it to google calendars to remind you when the birthday comes.{Well I think everyone remembers her/his birrthday :-) }

Get Directory Size using Python

Image
Well, I always wondered the scope of Python and Finally Realised it is limitless.
The following script named "DirectorySize.py" is written in python 3.x


The following python script has following properties

requires python 3.x to run Tell the size of directory in which it is placed Tested on Unix(MacOs and Ubuntu) But should also work on windowsTry, test, run and then write your own And I forgot something, Hello everyone  :-)

2D Numpy Arrays

Image
Let's recreate the numpy arrays.
If you ask for the type of these arrays,Python tells you that they are numpy.ndarray. `numpy`. tells you it's a type that was defined in the numpy package. `ndarray`
stands for n-dimensional array. The arrays `np_height` and `np_weight` are one-dimensional
arrays, but it's perfectly possible to create 2 dimensional, three dimensional, heck even
seven dimensional arrays!
You can create a 2D numpy array from a regular Python list of lists. Let's try to create
one numpy array for all height and weight data of your family, like this:
If you print out `np_2d` now, you'll see that it is a rectangular data structure: Each sublist
in the list, corresponds to a row in the two dimensional numpy array. From `np_2d.shape`,
you can see that we indeed have 2 rows and 5 columns. `shape` is a so-called attribute
of the `np2d` array, that can give you more information about what the data structure
looks like.

In[1]:import numpy as np In[2]: np_heigh…

Numpy (Numeric Python)

Image
NumPy is the fundamental package for scientific computing with Python. It contains among other things:
a powerful N-dimensional array objectsophisticated (broadcasting) functionstools for integrating C/C++ and Fortran codeuseful linear algebra, Fourier transform, and random number capabilitiesNumeric Python Alternative to Python List: Numpy ArrayCalculations over entire arrays Easy and Fast Installation ● In the terminal: pip3 install numpyor python3 -m pip install numpyIntroductionIn[6]:import numpy as np In[7]: np_height = np.array(height)In[8]: np_height Out[8]: array([1.73,1.68,1.71,1.89,1.79])In[9]: np_weight = np.array(weight)In[10]: np_weight Out[10]: array([65.4,59.2,63.6,88.4,68.7])In[11]: bmi = np_weight / np_height **2In[12]: bmi Out[12]: array([21.852,20.975,21.75,24.747,21.441])
First we imported the numpy package as np then, we created a new numpy array using "np.array(LIST_NAME)"
Element Wise CalculationIn[<