Home‎ > ‎Open source software‎ > ‎

Python




The Python programming language is free to download and install. Python is easy to learn and fun to use because its syntax is cleaner than that of many other programming languages. You need not be a professional software developer to enjoy working with Python. It's an excellent 'first language' or 'hobby language.'

Note: On my blog, Dave's tech docs, I write Python documents that include clear explanations and accurate procedures.

Installing Python

Before you can run Python examples, such as those in the sections below, you need to first install Python and an appropriate Integrated Development Environment (IDE). For Python, the most popular IDE is IDLE.

This web page applies primarily to Python version 3. Therefore, before you can run any example below you need to install both Python 3 and IDLE for Python 3.

Running Python examples

To run a Python example, do the following:
  1. Display the example you want to copy. For example, in the section below, you can click on Python Math Operations to display its code in a text file.
  2. Select all the text in the example file, and then press Ctrl+C to copy it.
  3. Open your Python IDE, such as its IDLE, and then open a new window.
  4. Place the cursor in the empty window, and then press Ctrl+V to past the code into the IDLE. This displays the code in full color.
  5. Run the code. For example, in IDLE, you can click Run Module to execute the program and display its results in the Python Shell.

Simple Python examples

The code examples below can help you get started with Python programming.

Python random functions

Python random-number functions can be great fun. For example, you can generate new words and automatic memos.

You can use the Python programming language to create random values, and concatenate strings (place them in sequence with no spaces among them). You can also combine random values and concatenated syllable strings to create new words. See the following Python code examples:
Python lets you define functions to generate humorous memos. Your defined functions select random words for sentences. An outer 'while' loop generates paragraphs. A nested, inner 'while' loop generates sentences by calling your defined functions. See the Python code example, Automatic writer.

Tkinter GUI for Python

Tkinter is the most common Graphical User Interface (GUI) package for the Python programming language. See the Python code example, Tkinter buttons and labels, to create a new window that contains active buttons and dynamic labels.

Tkinter Themed Tk (ttk) widgets let you program Python GUI data-entry interfaces for both text and numerical values. See the Tkinter ttk data entry code example to enter data through ttk.Entry widgets, and display data through ttk.Label widgets.

The following procedures can help you enhance your Python GUI windows by applying styles to your ttk widgets. These two Python programs generate similar windows: