A Python script is basically just a text file in which you input your Python code in order to build a larger application. Since the Python interpreter is suitable for small tasks and chunks of code only Python scripts allow you to build programs having hundreds or thousands of lines of code, make changes to your code and run it as many times as you want. The main thing you have to remember here is that each Python file or script must have the.py extension, not dot txt or anything else. Furthermore, you can name your script however you like, just as with any other file on your system. Now, in order to create and edit the text within your Python script, you must use a text editor. You are allowed to use almost any text editor on the face of the earth.
However, keep in mind that some text editors provides Some additional and very useful features when dealing with code. For instance, you can use notepad to write your Python script. But note that doesn't provide programming features like syntax highlighting, which, as its name suggests, highlights some Python specific words using predefined colors just to make your code easier to read. That's why I choose to use notepad plus plus, which is a free text editor that you can download from notepad plus plus.org. Just open their website, go to download and search for the latest version, which may be labeled as current version right here. Now scroll down and click on the notepad plus plus installer 64 bit in my case, to download this software for Windows 10.
After the download has been completed, just install notepad plus plus as you would do with any other piece of code. The installation process is pretty straightforward. Next up Pull up notepad plus plus I have it already installed. And let's analyze it a bit. First, you should configure the font size as we did with pythons IDL. To do this, just go to settings, style configurator and then choose your font and font size right here.
And finally, just remember to hit save and close to apply your changes. Now let's write our first Python script. For this I'm going to use a Python function that does nothing more than printing the characters in between its parentheses to the screen. So let's write this inside our script. Okay, next I will use File, Save As, then enter the name of the file, let's say file one and choose the extension from the Save as type list. We want to create a.py file because that's the file extension we need for any Python script.
So we will choose Python file Right here. Also, you should choose the location in which to save the file, I will save it to my D partition, save, you've just created your first Python script. Now it's time to run our small application, we can do that by simply opening the windows command line again CMD and typing in Python, a space and then the name of the file we just created. Also, remember to add not just the file name, but also the path to that file and very important the.py extension. So in my case, that would be d phi one dot p y. As soon as you hit enter, the program will print out Hello Python to the screen, according to the print function.
Inside the program, you have just built your first Python script and successfully ran it so congratulations for this