Getting Started with Python: Installing and Exploring Interactive Mode

Sari Lakkis
3 min readMay 13, 2021
Python in Action

In this article, we’ll start learning Python programming by setting up our environment and writing our first line of code.

Let’s start.

Setting Up Our Development Environment

The first thing we want to do is to set up our development environment and we mean by that the applications we want to install that allow us to start writing python applications.

Download and Install Python

The first thing we will do is installing the latest version of Python. Go to the official python website python.org and download the latest version according to your system (Windows X86 or Windows X64, Linux,.. etc).

For example, if you are working on a Windows 64-bit, machine then you need to install the files (Windows x86–64 executable installer) or other installer option. Install it and let’s check if it’s installed now.

In Windows, from your search bar search for cmd and click on it. A window called “command prompt” is started, this is also called a “DOS window” as the old DOS operating system uses text commands to work with your computer rather than the graphical user interface used in today's operating systems.

We will use this type of application (command prompt) in our tutorial while learning programming. It might look confusing at the first sight but always remember that it or any other tool is here to help us and to make things easier.

Now enter the command py and hit on return, it should type something like this:

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Any other messages typed, means that we didn’t install Python successfully so go back and install python correctly, it’s also a good thing to search for the message that you received and check online if it’s an error and how to fix it.

Python in the Interactive Mode

If everything is OK, then we are ready to start writing code and run it instantly, how? what we did by typing py is that we started the Python interpreter in the Interactive mode.

The interpreter is a kind of program that can understand the code (script) we write in Python and translate (compile) it to another form, called bytecode, that can be understood by the machine, and it’s the code that can be executed. So when we write our applications in Python, our code is then translated to bytecode by the interpreter, then this bytecode consists of the material of the application that the final user has and installs and what we have written in the source code.

The “interactive mode” means that we can directly enter Python statements and make them execute, let’s see how.

Our first line of code

Now type in the command window the following line:

>>> print('Hello world')

And the command window directly puts Hello World on the screen. This is the first statement that we write when we learn a new programming language.

The statement simply uses the print function to display everything written inside the single quotes as it is on the screen, not that much of a job indeed so let’s try an expression like 3.14 * 9.

The interpreter evaluates the expression and displays the results.

>>> 3.14 * 9
28.26

This is what we meant by interactive mode, a way to write the code interactively with the interpreter, this is an important feature that comes with Python and can be used as a type of advanced calculator or quick script validation.

Now to exit from the interactive mode, we simply enter the command exit() to return to the default command window.

Congratulations! You have written your first code, now we can go further and learn more about the Python language in the next tutorial.

--

--

Sari Lakkis

Professor | Consultant | Researcher. I give advice on strategy, design, and implementation of software that solves business problems to companies and startups.