Python for Machine Learning Pt. 1

What is Python?

Python is a high level, simple, easy to use and read yet relatively slow programming language. Its versatility, community, simplicity and presence of diverse libraries makes it a favorite for a lot of tasks, including Machine learning.

We will be giving you a path to learn python, which you should follow with a lot of practice of your own. So, let’s get started!

Boolean’s Git repository: here

Refer to “intro to python-1” for this blog.

First program

As an unsaid programming tradition our first program shall be “Hello world!”. In python its relatively easy. Just write print(“Hello world!”) and it’ll get the job done.

>>> print(“Hello world!”)Hello world!

Easy right?

Data Types

In python, there are various data types like:

· String (any word or sentence)

· Integer (any integer number)

· Float (any decimal number)

· Bool (True or False/ 0 or 1)

Moreover, the equal sign (=) is used to assign values to variables.

counter = 100 # An integer assignmentmiles = 1000.0 # A floating pointname = “John” # A string


Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the string and working their way from -1 at the end.

The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetition operator. Also, python indexing starts from 0 not 1

>>> print str #Prints complete stringHello World!>>> print str[2:5] #Prints characters starting from 3rd to 5thllo

For more about strings, refer to “intro to python-1” in Boolean repository

Basic operators

Assume variable a holds 10 and variable b holds 20, then-

Source: Tutorialspoints

You can run the verify the above results.

If else statements

The if/else statements in python works the same way as in other languages, only with a simpler syntax

Decision structures evaluate multiple expressions which produce TRUE or FALSE as outcome. You need to determine which action to take and which statements to execute if outcome is TRUE or FALSE otherwise.

Source: Tutorialspoint

You will find more examples in “intro to python-1” in Boolean’s git repository


A loop statement allows us to execute a statement or group of statements multiple times. The following diagram illustrates a loop statement –

Source: Tutorialspoint

You will find examples in the git repository notebook “intro to python-1”.

Find the introductory blog here

Written by Ashutosh Arya



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store