12 Basic Commands with NumPy Array

NumPy (pronounced as Num-pee or Num-pai) is one of the important python packages (other being SciPy) for scientific computing. NumPy offers fast and flexible data structures for multi-dimensional arrays and matrices with numerous mathematical functions/operations associated with it. Core data structure in NumPy is “ndarray”, short for n-dimesional array for storing numeric values. Let us… Continue reading 12 Basic Commands with NumPy Array

How to read a numerical data/file in Python with numpy?

Often you may need to read a file containing numerical data in Python for. One of the options is to import the file/data in Python is use Python’s NumPy library. There are number of advantages to use NumPy. NumPy is designed to deal with numerical data, it is fast and it has loads of built-in… Continue reading How to read a numerical data/file in Python with numpy?

How to Fold a Long Single Line Text to Multiple Lines (in Python and Linux)?

You might want to convert a really long string in a single line into multiple lines with specified width. For example, if you have string like 12345678912345678912345678912345678912345678910 and want to split the long text to multi-line text, where each line is of length w, like w=9 123456789 123456789 123456789 123456789 123456789 10 In the above… Continue reading How to Fold a Long Single Line Text to Multiple Lines (in Python and Linux)?

“with” statement in Python to Open a file

A common way to work with files in Python is to create file handler with “open” statement and work with the file. After finishing the work with the file, we need to close the file handler with close statement. For example, if we want to read all lines of a file using Python , we use… Continue reading “with” statement in Python to Open a file