Basic data types in Python language

In today’s post, I am going to cover the basics concepts of the python programming language.
Although most of the data science tutorials on the internet start of with libraries like numpy, sci-kit-learn and pandas it would be better if we first try to cover the absolute basic data types and syntax and how to play around with them before we deep dive into specific libraries because sometimes it’s good to watch individual Avengers and Guardians of Galaxy movies before trying to soak in the awesomeness of Avengers as a whole.
Let’s start off with basic data types:-

Numbers:- In python, numbers are represented either by using integers or float.


Strings:- Any collection of characters viz words or sentences are represented using strings in almost all of the programming languages.

The list of methods that can be used to manipulate lists are as follows:-

The first thing to keep in mind is that indexes start from 0 in python therefore when we print “user[1]” in the second line we actually get “o” which is the second character in the string. We have used “:” operator in the third line to specify the range of characters which we want to extract from a string. So when we specify the range from 1 to 3 above, we actually starting from the second character i.e. index 1 till index 3 i.e. 4th character.

Lists: Lists are used to represent a collection of similar items just like arrays in JavaScript or Java.

Some of the methods of python lists are:-

Keep in mind that if we use a negative value as an index then python will start counting items from the end of the list. For example, using “-1” as the index will print the last value from the given list.

In order to get specific items from the above list we can make use of “:” operator similar what we did in the case of a list.


Tuples are other data types similar to lists. They differ from lists in the following ways:

  1. They start and end with a parenthesis() instead of square brackets[].
  2. They are immutable i.e. they cannot be changed once declared. So think of tuples as read-only lists.

Let cover some basic tuples operations:-

Arithmetic Operations:-

Let’s cover basic arithmetic operations in the snippet below:

Logical Operators:

There are 3 main logical operators in python:-

Well, that finishes of today’s basic tutorial. In the next one, we will try to cover conditional loops and how to define functions in python language.

You can follow us on Facebook or Twitter for getting updates on the next programming tutorial. Till then have a nice day and happy coding 😀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Secured By miniOrange