The first step in Python is hello world

  • 2020-04-02 09:31:33
  • OfStack

First, download the latest version of python. (link: http://www.python.org), currently version 3.1.

The next step is installation, and python installation on Windows is like any other application, without much repetition.

Under Windows, you can use either the command line or IDLE to develop python. Start with the command line: set the PATH and add the python installation PATH to the PATH environment variable. Type python on the command line, the corresponding version number is displayed, and you enter the python working environment. The alternative is IDLE, which is the development environment installed by default in python.

Next, try out the most traditional and well-known hello world program.

Python is a scripting language. So, you can run it interactively or as a file.

First, introduce the interactive way: open IDLE and type the print('Hello world') command to get the output of Hello world. Same as this method on the command line.

Next, save the python statement to a file and run the python file. In IDLE, select File -- > New Window, in the New Window to write the previous python statement, save as hello.py file. Click run or f5 to run. Use python commands if you need to run python files on the command line. Go to the directory where the.py file is located and type python hello.py. Or simply specify a python file path in a command.

So, the simple "hello world" is done. Move on!

Related articles: