1. Home
  2. Docs
  3. Python 101 – Python Programming for Beginners
  4. Interactive Python Shell

Interactive Python Shell

Python Shell

Python standard installation comes with an IDLE an IDE (Integrated Development Environment) and

a Python Interactive Shell, usually called as Python Shell.

With which you can write, run, and debug code.

There are multiple ways to run Python code, which are discussed in later section.

In this section we will cover Python Interactive Shell.

Here in this section let’s use Python as a calculator.

Lets get started.

On Windows.

1. From start menu find Python 3.6  program,

on windows invoke python shell

2. Under Python 3.6  click on IDLE(Python 3.6 xxxx)

it will invoke a Python shell

python shell

At this point Python shell is started,

The first line Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32

tells us the version of the Python running at the moment, i.e Python 3.6.3

 

Now let’s do some math

Addition

Like in maths type, two numbers with math sign in between and hit enter.

#1

type 2 + 2 on the shell and hit enter

>> 2 + 2

4

>>>

#2

>>> 2 + 1.0

3.0

>>>

 

#3

 

>>> 1.6 + 2.6

4.2

>>>

#4

>> 5 - 3

2

>>>

#5

>> 100 - 1.5

98.5

>>>

#6

>> 10 -18

-8

>>>

#7

>> 4 * 5

20

#8

>>> 2/5

0.4

#9

>>> 4/2

2.0

#10

>>> 1/2

0.5

#11

>>> -1/3

-0.3333333333333333

>>>

Learn more about arithmetic operators.

 

You can also start the Python shell by using CMD program.

run CMD program on windows, and type Python3

 

python shell from cmd program

and you’re presented with Python shell, which is similar to the one you used above.

Just play around with Python shell.