All Courses

IPython - Getting Started

Geeta Sawrikar

2 years ago

Python - Getting Started | insideAIML
Table of Contents
  • Starting IPython from Command Prompt.
  • Start IPython from conda prompt
  • Magic Functions
          This chapter will explain how to get started with working on IPython.

Starting IPython from Command Prompt.

          Before proceeding to understand about IPython in depth, note that instead of the regular >>>, you will notice two major Python prompts as explained below −
  • In[1] appears before any input expression.
  • Out[1] appears before the Output appears.
Besides, the numbers in the square brackets are incremented automatically. Observe the following screenshot for a better understanding −
Now, if you have installed Anaconda distribution of Python, open Anaconda prompt from start menu.

Start IPython from conda prompt

          When compared to regular Python console, we can notice a difference. The IPython shell shows syntax highlighting by using different colour scheme for different elements like expression, function, variable etc.
Another useful enhancement is tab completion. We know that each object has one or more methods available as defined in its class. IPython pops up appropriate list of methods as you press tab key after dot in front of object.
In the following example, a string is defined. As a response, the methods of string class are shown.
IPython provides information of any object by putting ‘?’ in front of it. It includes docstring, function definitions and constructor details of class. For example to explore the string object var defined above, in the input prompt enter var?. The result will show all information about it. Observe the screenshot given below for a better understanding 

Magic Functions

          IPython’s in-built magic functions are extremely powerful. There are two types of magic functions.
  • Line magics, which work very much like DOS commands.
  • Cell magics, which work on multiple lines of code.
We shall learn about line magic functions and cell magic functions in detail in subsequent chapters.
  
Like the Blog, then Share it with your friends and colleagues to make this AI community stronger. 
To learn more about nuances of Artificial Intelligence, Python Programming, Deep Learning, Data Science and Machine Learning, visit our insideAIML blog page.
Keep Learning. Keep Growing. 

Submit Review