Python Basics

Most Windows and Mac computers come with Python pre-installed. You can check that via a Command Line search. The particular appeal of Python is that you can write a program in any text editor, save it in .py format and then run via a Command-line. But as you learn to write more complex code or venture into data science, you might want to switch to an IDE or IDLE.

What is IDLE (Integrated Development and Learning Environment)?

IDLE (Integrated Development and Learning Environment) comes installed along with all python installations. It makes use of Text highlight, where it make use of different colours to identify variables, function, commands, etc. This gives an advantage to the developer in findings errors. Python IDLE has a build Automator of some kind that compiles the code, and builds an executable program by adding in any necessary libraries, some of which you may not even be aware of. Those same tools make it easier to organize and include any optional libraries, or ones you've created yourself.

Shell is the default mode of operation for Python IDLE. In essence, it's a simple loop that performs that following four steps:

Note: Python shell is a great place to test various small code snippets.

Main Python Data Types

Everything in python is implemented as an "object". Every "object" has a specific "Data type". The 4 most-used datatypes are as follows:


Integers (int) — an integer number to represent an object such as "number 3".

<class 'int'>
-2, -1, 0, 1, 2, 3, 4, 5

Floating Point

<class 'float'>
-1.25, -1.0, -0.5, 0.0, 0.5, 1.0, 1.25


Encode a sequence of characters using a string. For example, the word “hello”. In Python 3, strings are immutable. If you already defined one, you cannot change it later on.

While you can modify a string with commands such as replace() or join(), they will create a copy of a string and apply modification to it, rather than rewrite the original one.

<class 'str'>
'Yo!', 'Hey', "what's up?", "Ola!!!"


A list is a sequence of objects. It is a mutable sequence. It can be defined as a list of objects, or a list of lists. For example, the list of numbers 1, 2, 3, 4, 5.

<class 'list'>
[-2, 0, 1, 3.1415, 'Hello, world!']

NOTE: There are more data types like sets, Dictionaries, complex numbers, tuples, boolean.