Last Updated:

Running Python programs in Sublime Text 3

Running Python programs in Sublime Text 3

Hello Python developers, here we will learn how to run python programs in the Sublime Text 3 editor, download and install Sublime Text 3, install packages and much more.

There are various IDEs and text editors for running python code. If you're a beginner, then it's okay to use a text editor, but if you're a developer, then no doubt you'll be familiar with the importance of the IDE. And you can also refer to this Best Python IDEs link for a detailed explanation of Python IDEs. Although Sublime Text 3 is a text editor, it does have some IDE-like features, such as projects and "assemblies" to run other programs from inside the editor.

Sublime Text Editor 3

 

Advantages

  • It is an easy editor for developers.
  • It is the most popular among developers.
  • The best thing about Sublime Text 3 is that it doesn't require a lot of space to install and working with it is very convenient and comfortable.
  • Sublime Text 3.0 was released on September 13, 2017.
  • It natively supports many programming languages as well as markup languages.

 

Features of Sublime Text 3

 

  • Cross-platform
  • Sublime Text 3 can run on Windows, Linux and Mac.
  • You only need one license to use Sublime Text 3 on each computer you want to use Sublime Text 3 on, no matter what OS they're using.
  • Powerful API and package ecosystem
  • Sublime Text 3 provides many powerful Python APIs that allow the plugin to perform many built-in functions.
  • Sublime Text exposes its internal components through an application programming interface (API) that programmers can interact with using the Python programming language.
  • A built-in Python interpreter is included in the editor. The built-in interpreter is useful for checking editor settings and quickly testing API calls when developing plugins.

Command palette

This is another powerful feature of Sublime Text 3. It allows you to perform various functions, such as sorting, changing syntax, as well as changing identification parameters.

Using the command palette, you can access many things, such as processing sublime projects, changing file syntax, invoking package commands, etc. To use the command palette – press ctrl+shift+p, then select a command and press Enter.

Multiple Choice

This is one of the best features of Sublime Text 3. Using this feature, you will be able to change several lines at the same time, as well as manipulate files faster. It works as a quick replacement to find and replace, or to apply the same sequence of changes to multiple rows at the same time.

To use multiple selection, select a block of text, then press Ctrl+Shift+L to split it by one selection per line, and then press Ctrl+D to select the next occurrence of the selected word.

Other Features

Apart from the above features, Sublime Text 3 also has some other features, such as:

  • Spell check function
  • Automatic saving
  • Customizable key bindings
  • Macros
  • Split editing
  • Advanced settings

Sublime Run Python Tutorial – Run your first program

Without a doubt, Sublime text is the most beloved text editor in the developer community and can serve as an excellent Python text editor. So now we'll see how to use it for python.

Download and Install

First of all, you have to download it. Download link-https://www.sublimetext.com/3 You will see a description of the version as follows:

portable version of python

And now you have to choose one of them as a requirement for your computer. Install the downloaded file.

Test a simple program

Now we will see the execution of the python program on SublimeText 3. To do this, we must do the following:

  • First of all, open your sublime editor.
  • Create a new file by following the steps file->NewFile or by pressing ctrl+N .
  • Then save this file as yourfilename.py. The extension must be .py.
  • Then write your code.

Here we take a simple program, that is, adding two numbers. So the code is:

num1 = 7
num2 = 9
# Add two sum numbers
= float(num1) + float(num2)
# Display the sum
of print('Sum {0} and {1} is equal to {2}'.format(num1, num2, sum))

Running the Code

Go to Tool on the menu bar, and then click build system and within it, choose Python. Then go to the Tool option section and click the Build option button, which will execute your code.

Running the Code

So, now, running the above code, we get the following output:

The sum of 7 and 9 is equal to 16

Congratulations, the python code works successfully on sublime! We hope that this article will be useful for you. And if you have any questions about SublimeText 3, leave your comments!