IPython (and Scripts)

Learn to Code Today!

Learn 10x faster: coding, no-code and data skills. Join millions of users mastering new tech skills and accelerating their career with Enki.
Get started

This is part of the “Intro to Data Analysis with Python” series of posts, with content from the Enki app. If you stumbled upon this, you could start from the beginning.

The Python language comes with a basic interpreter and a REPL[1] that lets us write and run Python programs.

IPython is an enhanced version of that with user-friendly features such as:

  • Auto-completion
  • Support for Data Visualization
  • Multi-line editing
  • Syntax highlighting
  • and more

The IPython shell is usually the recommended shell as it runs your Python code just like the normal Python shell does while also providing a richer set of features on top[1].

The IPython interpreter, as well as the basic Python interpreter, are both interactive shells that are accessed through the terminal via the python / ipython commands.

If we save code into a file, we call that file a script.

If we give the name of our file to the Python shell, we can have it execute the code for us.

💡 Scripts are executed in the same way as regular, command-line code.

Footnotes

[1: REPL]

REPL, or Read-Eval-Print-Loop, is an interactive programming environment.

It allows you to type commands directly into the interpreter. The command then get executed and the result is returned to the user.

[2: Multi Line Execution]

Here is the same code run on the basic interpreter vs IPython:

Basic interpreter:

IPython:

💡 In iPython, you can re-run any part of code you've already run with or without modification to the code.

iPython lets us store multi-line code blocks behind special Line [N] variable names. If you look at the iPython example above, all of the code was run on Line [1]. This lets us split code into sections and re-run or re-use any section at any time.

On the other hand, in the regular interpreter, we had to write all lines of code one by one.

In any terminal, pressing the ⬆️ key would give us our last executed line.

If we press ⬆️ in iPython, it would give us last executed Line.

❗ The multi-line editing feature is not available within the iPython terminal and only available in notebooks (more on this to come later)

You can think of notebooks as interactive Python environments that can combine code execution, rich text, charts, and rich media.

About Enki

  • Fully personalized online up-skilling
  • Unlimited AI coaching
  • Designed by Silicon Valley experts

More articles

Meet your AI-enabled coach

Professional athletes have a coach for every aspect of their performance. Why can’t you for your work? Enki’s AI-powered coaching on-demand - combined with state of the art, structured learning content - makes this a reality.
1
1:1 AI Coaching
How do I remove duplicate emails?
Convert the list to a set and back to a list. Sets automatically remove duplicates.
2
Personalized Exercises
3
Interactive practice

Unlock full access to all skills on Enki with a 7-day free trial

Get started