What is IPython?

Learn about IPython and IPython notebooks.

IPython

For a long time, we used IDLE, which is the default GUI Python client. IDLE can be difficult to use. For example, if we press the up key, it doesn’t take us to the last command. Instead, it moves the cursor up. If we want to run the previous command, we must press up multiple times until the cursor touches the command we want and press enter.

It is also difficult to implement directory changes. We have to search through the OS library commands, and even then, we may not get what we want.

This is why we’re introducing IPython. It is easier to use and more intuitive than IDLE. We can use standard Linux commands like ls, pwd, and cd to move around, and we can run python scripts online as well. We usually use the following IPython Qt Console version:

There is another incredible thing called an IPython notebook that we’ll look at now.

IPython notebook

IPython Notebook is the old name for the now famously used Jupyter Notebook.

The Jupyter Notebook Application is a server-client application that allows editing and running notebook documents via a web browser. The application can be executed on a local desktop and requires no internet access nor an installation on a remote server accessed through the internet.

IPython notebook, aka Jupyter Notebook, allows us to put text, graphics, and Python code in a web-based file that can be shared with others. This is great for writing tutorials, as the user doesn’t have to copy-paste the code. They can run the notebook directly and see the explanation and the code running at the same time.

IPython provides a rich architecture for interactive computing. It has features like:

  • a robust interactive shell.

  • a kernel for Jupyter.

  • support for interactive data visualization and use of GUI toolkits.

  • flexible and embeddable interpreters to load into our projects.

  • easy to use, high-performance tools for parallel computing.

Coding with the IPython notebook

We won’t use the IPython notebook much, but let’s learn how to write a code in IPython and execute it. If we take a look below, we’ll see what an IPython’s Jupyter notebook kernel looks like.

Click the “Click to launch app!” button and see what happens. If you see the following pop-up, just click “OK”.

Please login to launch live app!

Now we’ll see the following webpage.

This is the first line of a simple Python code. Click the “Run” button, shaped like a triangle, to see what every line of code does. When we enter ‘In’ , it returns ‘Out’.

print ("I can put in Python code")

This print() function simply prints everything that’s written inside the function.

In In(5), we wrote code for plotting a sine wave and a cosine wave.

In In(6), the pwd command outputs the directory we’re currently viewing.

Now go ahead and write any piece of Python code to see its instant output.