Python3 Interpreter
On Linux/Unix systems, the default Python version is generally 2.x. We can install Python3.x in the /usr/local/python3 directory.
After installation, we can add the path /usr/local/python3/bin to the environment variables of your Linux/Unix operating system, so you can start Python3 by entering the following command in the shell terminal:
On Windows, you can set Python’s environment variables using the following command, assuming your Python is installed in C:\Python34:
Interactive Programming
Section titled “Interactive Programming”We can start the Python interpreter by entering the “Python” command at the command prompt:
After executing the above command, the following window information appears:
Enter the following statement at the Python prompt and press Enter to see the execution result:
The above command produces the following result:
When typing a multi-line structure, line continuation is required. Let’s look at the following if statement:
Scripted Programming
Section titled “Scripted Programming”Copy the following code into a hello.py file:
Execute the script with the following command:
The output is:
On Linux/Unix systems, you can add the following command at the top of the script to make the Python script directly executable like a SHELL script:
Then modify the script permissions to make it executable:
Execute the following command:
The output is: