Open In App

How to setup Notepad to run Python Script

Last Updated : 13 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Due to its simplicity, versatility, and readability, Python has become phenomenally popular as a computer language that is highly leveled and dynamically typed. These are some of the IDEs for Python development that have many tools; however, if you are just starting or want it lighter, then Windows’ simple text editor – Notepad can be an option to start with. This article immerses in Python usage via Notepad—highlighting steps involved, breaking down underlying concepts, and eventually weighing up the pros versus cons of this approach.

Installation:

  • Get the newest version of Python from its official website: (www.python.org/downloads)
  • Python Installation Process

Note: While doing the installation process select “Add Python to PATH”. It will allow using Python from any command prompt easily.

Steps to Use Notepad to Run Python Program

Perform the following steps to write and execute a Python script on Notepad:

  • Click on the notepad icon on your PC and start typing the Python code you want to write. Then save it with a .py extension.
  • Save your Python script. Ensure you select “All Files” for the file type when saving and give it a .py extension.
  • Open Command Prompt (CMD).
  • Navigate to the Script’s Directory:
  • Use the cd command to navigate to where you have stored your Python script by changing the directory.
  • Now run your Python script by entering this command:
python script_name.py

Implementation

For this illustration, take a simple Python script as pythonfile.py, save it, and then open the command prompt to the folder in which you saved it. Here there is a Python script with the code shown below:

np

Run Python Script using Notepad

To change your directory type this command into the following:

cd path\to\your\script\directory

np

And you can run your file from window console by typing:

python script_name.py
Guild to setup Notepad to run Python Script

OUTPUT

Conclusion:

Nevertheless; while this program is suitable for small Python scripting tasks, it’s limited when handling complex ones. Better yet opt for dedicated Python IDE (Integrated Development Environment) or Code Editor to have better code control ,debugging operations and functionality. The popular examples include Pyacharm, Spyder, VSCode editor etc.

Related Article: Python Tutorial


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads