Something about programming

Python interactive shell and interpreting of .py files

Next tutorial: Python syntax and build-in types

In this tutorial we will learn how to work with Python interactive shell in Windows and Linux and how to run files with Python source code.

Interactive shell

Interactive shell allows to run Python code in dialogue mode, i.e. you input the command and immediately see the result.

Interactive mode is started by python.exe file in Windows or by python (python3) command in Linux. It will start interpreter from Python directory. You need just input python in command line.

My path to interpreter - C:\python34\python.exe, you will have another. At start of interactive shell you can see Python version installed on your computer. On screenshot you can see v3.4.2, I'm currently using v3.5.2 and the latest Python release - 5.6.0 (january 2017).

Starting Python interpreter with graphical user interface (GUI) - IDLE

IDLE is very simple IDE for Python. On one hand in the IDLE word there are three letters coincide with IDE, on the other hand IDLE is named after Eric Idle - member of Monty Python (it's for them Python is named).

    On Linux you'll need to install IDLE manually - it's not the part of standard package. For Windows users: you can run IDLE differently
  • Run it from the Start menu. IDLE will be listed in the file list for Python.
  • Go to the directory where Python is installed. Then, go to lib\idlelib. Here you can run idle.bat, or idle.pyw - they all work.
  • Through command line. Go to the directory where Python is installed, then run one of next commands (exe extension is not necessary):
    python.exe lib\idlelib\\npython.exe lib\idlelib\idle.pyw

IDLE has py or pyw extensions. These are standard extensions (pyw - for windows, but you can use py on windows too). You can open or idle.pyw in any text editor - there you will see python source code.

On the next screenshot there is running Python interpreter in Idle:

There are many more powerful IDE's for Python. As for me, I'm using Sublime text editor most of the time.

Python interpreter commands

Let's try to write something in Python. Start interactive shell and input next commands:

>>> 2+2 >>> "Hello!" >>> print("Hello!") >>> v = "Hello!" >>> print (v) >>> v = 2 + 2 >>> print(v)

When you input command and press Enter, interactive shell executes the command and outputs the result.

To exit from interpreter you can input quit() or Ctrl+Z:

>>> quit() >>> ^Z

Running .py files

As I mentioned earlier, files with Python source code usually have .py extension. You can run them with the command python (or python.exe) with argument - name of the file, which you want to run.

Let's create file in any directory. Open it in text editor and paste next string:

print( "Hello!" )

Now in command line you need to go to the directory there you've created file. And here you need to input:


Your code will be executed and in console you will see greetings.

On this screenshot you see the word "Привет" (prievet), it's "hello" in Russian.


We've learned how to run Python interpreter and files with Python source code. You can work with Python interpreter in any operating system (Windows, Linux, XOS). All you need - just install Python interpreter and preferable text editor or IDE. In next tutorial we will learn Python basics.


June 20, 2018, 6:07 p.m.
1 Guest
<a href= >buy cheap cialis online</a> here "" - cialis online generic cialis
June 21, 2018, 6:55 a.m.
2 Guest
<a href= >buy cheap cialis online</a> here "" - cialis online generic cialis
July 14, 2018, 3:20 p.m.
3 Guest
My Canadian Pharcharmy Albendazole Canadian Pharmacy <a href=>cialis no prescription</a> Keflex And Diflucan Celebrex Discount Coupon
Aug. 15, 2018, 9:17 a.m.
4 Guest
School life and college life essay writing College student union essay writing Swimming essay writing The evils of poverty essay writing If i were a dictator essay writing <a href=>write movie reviews online</a> Hobbies essay writing The problem of illiteracy in our country essay writing Should people stop using Facebook Why or why not essay writing Failures are the pillars of success essay writing School life and college life essay writing Should your school adopt a school uniform policy Why or why not essay writing It my first day at college essay writing Tragedy essay writing Leisure essay writing Our intended profession essay writing Describe a difficulty that you have had to overcome essay writing Pros of genetic engineering essay writing Explain why ancient Greek mythology is still relevant today essay writing The happiest day in my life essay writing The value of discipline essay writing how to write a successful cv igcse maths textbook objective for resume igcse economics revision certificate education
Aug. 20, 2018, 3:40 p.m.
5 Guest
The evils of industrialism essay writing Scene in a public park essay writing A boat-trip in moonlight essay writing Our intended profession essay writing Compulsory games in schools and colleges essay writing <a href=>buy resumes online</a> Science and human life essay writing Pros of genetic engineering essay writing Connection between robotization and world poverty essay writing How do you propose to spend the long vacation essay writing National defense essay writing Community development essay writing Vocational education essay writing The probable secret of success essay writing Honesty is the best Policy essay writing A secular state what it means essay writing Teaching children with learning disabilities essay writing Socialism essay writing The dignity of labor essay writing What famous person dead or alive would you most like to talk to Explain why essay writing Literature and society essay writing english igcse expert resume writing topic essays term papers essays custom term paper writing services