How to Run Python on Ubuntu
Python is a high-level open source programming language used both as a scripting language and a way to create high-level graphical programs. The Ubuntu Ubiquity software installer is written using the Python language. It is installed natively on the Ubuntu operating system as well as on other Linux distributions, and Python scripts can be run from within the command line Python interpreter. They can also be saved as plain text files and executed using the "python" command.
Instructions
-
Run Python in Interactive Mode
-
1
Right-click on the desktop and click on the "Open in Terminal" option to access a command prompt.
-
2
Type the command "python" with no arguments to open Python's interactive mode.
-
-
3
Type the line "print "Hello!" and press the "Enter" key. The word "Hello" will appear beneath the line.
-
4
Type the line "exit()" to close the interactive editor.
Run External Python Script
-
5
Right-click on the desktop and click on the "Open in Terminal" option to access a command prompt.
-
6
Type the line "python filename.py" and press "Enter" to execute a script stored in a text file. The command prompt will return when the script is finished executing.
-
7
Type the command "exit" to close the terminal window.
-
1
Tips & Warnings
You can create an Python executable file by typing "#!/usr/bin/python" as the first line of the Python script. Change the file permissions to "executable" to execute the script.