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.

Advertisements

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.

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 Addition.py in a directory called python_projects.

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.

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

The output of the above script is displayed as follows.

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.

Advertisements

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Exit mobile version