Python Scripting Mode


In the previous article, you learned about the python IDLE and interactive mode. You will learn about scripting mode of python in this article. The scripting mode allows you to run python files.

Python Files

A python file is a script with .py extension. The interactive mode doesn’t allow you to run scripts inside a python file. Therefore, you need to open the script in python script mode and execute it to get the results.

Python Scripting Mode

To open the scripting mode go to IDLE and press – ctrl + N. This will open a new “Untitled” script file. Look at the figure below.

Script Mode with a Untitled file
Figure 1 – Script Mode with a Untitled file

Before you start writing code, make sure you save the file in a directory of your choice.We saved our file as in a directory called python_projects.

Save your script in a directory with .py extension.
Figure 2 – Save your script in a directory with .py extension.

Writing and Executing Codes

While the file is open, simply write your code and use the “Run” tab to “Run Module” to execute the code. For example, the following script will print “Hi” as output.

Execute Python Script from Run > Run Module
Figure 3 – Execute Python Script from Run > Run Module

The output of the above script is displayed as follows.

Output From Python Script
Figure 4 – Output from Python Script

Note: Make sure that you save your script changes before executing it, otherwise, you won’t get the correct output.

In the next article, we will discuss about the programming paradigms.


Let Us Python – 4th Edition: Python Is Future, Embrace It Fast

This book is for everyone who wish to learn python programming language. It strengthens the foundations, as detailed explanation of programming language concepts are given. Lists down all important points that you need to know related to various topics in an organized manner. Prepares you for coding related interview and theoretical questions. Provides In depth explanation of complex topics and Questions. Focuses on how to think logically to solve a problem. You will learn about Data types, Control flow instructions, console & File Input/output Strings, list & tuples, List comprehension Sets & Dictionaries, Functions & Lambdas Dictionary Comprehension Modules, classes and objects, Inheritance Operator overloading, Exception handling Iterators & Generators, Decorators, and Command-line Parsing