Four ways to run python code directly | Laptrinhcanban.com

HOME › >>

Four ways to run python code directly

Posted at: https://laptrinhcanban.com/en

In this article, we will learn four ways to run python code directly on four programs that create the popular python programming environment.

Select a program to create a python programming environment

To run python, you need a software that creates a python programming environment so that we can enter the python code and run it. There are many python programming environments to choose from, you can choose from one of them below.

Command Prompt

Command Prompt is a built-in Windows program that helps you run python code directly on the DOS platform. You can refer to how to start Command Prompt at How to start Command Prompt on a computer.

In addition to using the Command Prompt to run python code, you can also use this program to run a program that has been saved in the python file. You can refer to the article How to write python programs, save and run python programs.

However, in order to be able to run python on the Command Prompt, there is a requirement that you have installed python on your computer, and installed the python environment on the windows operating system.

Command Prompt

You can also replace Command Prompt with Windows PowerShell. Both of these programs provide a DOS platform that helps to run python code directly.

Windows PowerShell

Anaconda Prompt

Anaconda Prompt is a program that helps enter commands and run python code directly. This is the software that is integrated when you install python with Anaconda. If you have installed python with Anaconda, you can start this program by going to the Anaconda Prompt icon in the Programs tab on the Start Menu, or you can press Windows key then enter Anaconda Prompt to find the program. Then click on the icon and launch it.

Anaconda Prompt

Like the Command Prompt, the Anaconda Prompt program can also be used to save a program to a python file. You can refer to the article How to write python programs, save and run python programs.

Jupyter-NoteBook

If you are used to manipulating directly on browsers such as Google Chrome or Coccoc, Firefox, you can use Jupyter NoteBook - a software that helps to run python code directly in the browser which is integrated when installing Anaconda.
Jupyter with the ability to save both commands and execution results such as logs or graphs, will help you save time when re-opening the program you are writing.

Project Jupyter (source: https://jupyter.org)


Project Jupyter (source: https://jupyter.org)

You can start Jupyter similar to Anaconda Prompt by looking for the program’s icon in the Programs tab on the Start Menu.

paiza.io

paiza.io is a website that provides an online platform to run programs written in many languages, including python. If you have not already installed python on your computer, then running online on this website is not a bad choice at all.
Paiza project (source https://paiza.io/en)

Paiza project (source https://paiza.io/en )

In the tutorials on laptrinhcanban.com , Kiyoshi also casually uses paiza.io as an online practice window to help you review knowledge in each article.

Run the python code

After starting one of the above software, we have the python programming environment ready. Now you can run the python code directly by entering the lines of python code on the screen of the above software, click Enterand execute them. For example you can use the following command line to check the version of python:

python --version

Let’s see the python command input screen and the returned results with the Anaconda Prompt software as shown below:

Summary

Above, Kiyoshi showed you four ways to run python code directly. To better understand the lesson content, practice rewriting today’s examples.

And let’s learn more about Python in the next lessons.

URL Link

https://laptrinhcanban.com/en/python/nhap-mon-lap-trinh-python/kien-thuc-can-ban-ve-chuong-trinh-python/lam-chu-bon-cach-chay-python-pho-bien/

Thank you for reading and please Like & Share for other friends to learn.
">

HOME  › >>

  • Recent Posts
Profile
きよしです!笑

Author: Kiyoshi (Chis Thanh)

Kiyoshi was a former international student in Japan. After graduating from Toyama University in 2017, Kiyoshi is currently working at BrSE in Tokyo, Japan. Kiyoshi là một cựu du học sinh tại Nhật Bản. Sau khi tốt nghiệp đại học Toyama năm 2017, Kiyoshi hiện đang làm BrSE tại Tokyo, Nhật Bản.