Skip to content

Getting Started with Python

This article will introduce how to start and run Python scripts.

1. Confirm Python Version

Assuming you have already installed Python, enter the following content in the Linux command line to confirm the Python version:

Bash
1
python --version

Output:

Text Output
1
Python 3.8.10

In the latest version of DataFlux Func (Automata), the Python version is 3.8.10

2. Enter Python Command Line

Python includes an interactive command line where you can execute simple Python scripts directly in the interactive command line.

Enter the following content in the Linux command line to access the Python command line:

Bash
1
python

Output:

Text Output
1
2
3
4
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

At this point, the cursor is after the prompt >>>, and you can now write Python scripts. Each line of Python script executes after pressing Enter, such as:

Python
1
print('Hello, World!')

Output:

Text Output
1
Hello, World!

In subsequent documents, Python code will not include the prompt >>> at the beginning

3. Writing Python Scripts in a File

We can also write the above Python script into a hello.py file and execute it using the python command.

Bash
1
python hello.py

It can also be changed into an executable script as follows:

Python
1
2
#!/usr/bin/env python
print('Hello, World!')

After making it executable, call and run it directly:

Bash
1
2
chmod +x hello.py
./hello.py

3.1 Print Function print

The print function in the example above is mainly used to output information, such as the print('Hello, World!') which means "output the Hello, World! text in the terminal".

You will see more use cases in subsequent articles.