Category: Python

Python tip: Assignment operators

How do you increase the value of a variable? Here are a few more operations: If you don’t know some of these operators (e.g. ** or //) check out the Python documentation. Notice how...

Good, Better, Best? : FizzBuzz

The Zen of Python states: “There should be one– and preferably only one –obvious way to do it.” In real life it is not always that easy. There are usually many different ways to...

Python tip: 1. 2. 3. Enumerate

Say you want to print a numbered list. For instance: Apples Bananas Oranges Pineapple How would you do this? Maybe like this: (The output has a space after each number, which doesn’t look right....

Python tip: Use for loops correctly

If you come from another language, like C, you may write a loop like this: Or perhaps you have discovered Python’s for loop so you use that to make i equal to 0, 1,...

Alphabet on blackboard

Tips for writing better Python code

I was a very experienced programmer when I started using Python. So I wrote some very bad Python code. Each language has its own way of doing things. The more you learn the language,...

Control your computer using Python

Python is an excellent language for taking control of your computer and performing some of the more tedious tasks. I recently used it to automate how I create Python training videos and have just...

A simple GUI (graphical user interface)

Python is an easy-to-learn yet powerful language, and comes with a wealth of libraries. It is often used to create simple scripts. You run these on the command line, giving it any parameters it...

Take out your turtle for a recursive walk

Python is a simple but powerful language, and comes with a wealth of libraries. It took just 10 lines of code and the Turtle library to create the black line in the image above....

A simple plot with Python and Bokeh

Python is a simple but powerful language, and comes with a wealth of libraries. The chart above took just 9 lines of Python. All the hard work is done by the Bokeh library. It...