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 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, 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 within the interactive command line.

Enter the following 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 now you can 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. Write 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 modified into an executable script as follows:

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

And after making it executable, call it directly:

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

3.1 Print Function print

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

You will see more use cases in subsequent articles.