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.
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.
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
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.
The output of the above script is displayed as follows.
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.