Home / Computer Science / Python / What is Python Shell

What is Python Shell

In the previous postings, we learn python is an interpreter language that means it executes line by line of code. Python comes with interactive shell known as python shell which is used to execute python coding lines or commands and the results view instantly after execution of the command.

See the below in the python shell.

What is Python Shell
                                         What is Python Shell


>>> print ("hello")
hello
>>> print 2+3
5
>>> print 2/5
0
>>>

Type a code or instruction and then press enter it gives results instantly like above.
To use python shell in your PC, type python in run and find Python Command line and click on that, the above screen is opened that is python shell.
Till now we learn the single command execution, in the case multiple line of code or python file execution follow the below steps.
Unlike Java and c python programs also execute from cmd.

Step1:
Create python program in note pad or python environment and save that file extension with .py. (remember that file location).

num1 = 1.5
num2 = 6.3
# Add two numbers
sum = float(num1) + float(num2)
# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))

I saved the above file with name sum.py in Documents folder.

Step2:

Open Command prompt and change directory to Documents.

See the below snap I was navigating to Documents folder.

Navigation in CMD
                                     Navigation in CMD

Step3:

Execute out program by typing Python Sum.py
Python programname.py (press enter) the program will execute. See below picture.

Python Program Execution
Python Program Execution

About santosh G

Hi, i am Santosh Gadagamma, a tutor in Software Engineering and an enthusiast for sharing knowledge in Computer Science and other domains. I developed this site to share knowledge to all the aspirants of technologies like, Java, C/C++, DBMS/RDBMS, Bootstrap, Big Data, Javascript, Android, Spring, Hibernate, Struts and all levels of software project design, development, deployment, and maintenance. As a programmer I believe that, “The world now needs computers to function.” Hope, this site guides you as a learning tool towards greater heights. I believe that Education has no end points and i wish to learn more in the process of teaching you….,

Check Also

Interview Questions for Python Strings

Unleashing the Power of Python Strings: Advanced Methods for String Manipulation

In this blog post, we will explore advanced methods for python strings that expand your …