· blog · 4 min read

How to Run Python Programs Easily

There are manu ways by which you can run python programs. Python works with an interpreter which comes with python download package.

In the learning process, you are going to run Python programs many times. There are many ways by which you can run python scripts or programs. As a beginner, you should focus on running Python programs easy way.

This tutorial will tell you different ways to run a Python program. You should learn all of them. Then you can choose whichever method you like. I will suggest that you should use the command line to run Python programs.

Python programs are run using a Python interpreter. Python interpreter comes along with the python bundle.  we downloaded this bundle in the previous lesson. 

If you haven’t installed Python yet then you should check the previous tutorial. Tutorial as a detailed guide how you can install Python3 properly.

Run Python Programs Using Command Line in Windows

run oython program in windows command line

Command-Line in Windows is amazing. You can do much stuff with the windows command line. Although, it has many different commands. We don’t need all of that. You just need basic CMD commands. You will use these commands to browse through the folders, etc. We don’t need all of the commands.

Below are the commands which you will use mostly.

  • cd : This command is known as change directory. The command is used to change directory. If you want to change directory to a different location, you can do it with this command. This command will useful if have programs in subfolders and different folders.
  • cd.. : Adding two full stops after cd command will take one level of the directory. It will take you one folder back of the current folder.
  • cls : It is known as Clear Screen command. Cls command is used to clear the screen when required.
  • dir : dire stands for directory command. This command lists all the directory in the current working path.

Run Python Programs in Mac OS Terminal

run python program using mac os terminal

Mac Os is based on UNIX. It has terminal like windows. Mac OS Terminal has different commands. Again, you don’t require all of them. You just need the basic ones.

Basic commands for changing directory and clear screen commands are enough.

For Mac OS terminal you can learn following commands.

  • pwd : pwd command prints the current working directory on the terminal. It will be useful for knowing which directory you are working on.
  • cd : cd command means change directory. This is the same as the windows cmd command. Change the path of the terminal with the change directory command.
  • ls : ls command lists all the files and folders in the current directory. You don’t have to go to the file manager every time.
  • clear : clear command clears everything on the terminal.

Online Python Interpreter

run python program using online interpreter

Online Python Interpreter are that you can use to run python programs. You don’t have to install anything on your PC. You can just go to the link and start writing and running your programs. It is good when you are working on smaller programs.

But when you start working with files and other complex programs, it becomes difficult to do it online. If you are starting out you can use online interpreter.

Some of the online python interpreter that I like.

Run Python Programs using IDEs

Standalone IDEs are available in the market. They have python interpreter built into the software. So you write python programs and run along the way. Just click a button and you are done.

Anaconda is one of the most popular IDE that is available for Python. For Anaconda, you have to download and install the package. Anaconda IDE is quite heavy.

Conclusion

These are some of the methods which you can use to run programs in Python. Now it is up to you whichever method you like you can use. My recommendation would be to use the command line for now. After that you can change for whatever you like.

Share:
Back to Blog