Home » Articles by: Brad Morton

What is a Python Dictionary? Explanation and Code Examples

Python dictionary

Here’s everything you need to know about the Dictionary data type in Python, what it can store, and how to use it. Python has several built-in data types for storing data (more than other languages like JavaScript) – from basic types like integers, floating-point numbers, and strings to more complex types like lists, tuples, and dictionaries. What is a Type? A variable’s type defines what kind of value it can store and what can be done with it. What is a Dictionary? A dictionary is a variable type … Read more

Home » Articles by: Brad Morton

How to Add/Append Items to a Dictionary in Python [Examples]

Add Item to Python Dictionary

This short tutorial will show you how to add single or multiple items (as key:value pairs) to a dictionary in the Python programming language. What is a Dictionary in Python? We’ve covered what dictionaries are in our article here. There are a couple of ways to add items to a dictionary, so we’ve put together this article separately to make sure we’ve got everything covered! Checking Whether a Key Exists in a Dictionary As outlined in the article linked above, dictionaries store data as a series of key:value pairs. Before … Read more

Home » Articles by: Brad Morton

Quick and Dirty CCTV with Raspberry Pi, MotionEyeOS + Webcam

home cctv motioneyeos

In this article, I’ll walk through the process of setting up MotionEyeOS on a Raspberry Pi, using a cheap USB webcam to create a DIY CCTV system. MotionEyeOS is a pre-configured Linux distribution that turns your Raspberry Pi into a home CCTV system.  You can set up multiple cameras and set them to detect motion or record on a timer, and send the resulting photos and videos to you via email or save them to online storage. What You’ll Need A Raspberry Pi A USB … Read more

Home » Articles by: Brad Morton

How to Merge Dictionaries in Python, With Examples

Python Merge Dictionaries

This article will show you the simplest ways to merge two or more dictionaries in the Python programming language. Note that the code examples in this article are written for Python version 3 – and will not work with Python version 2! What is a Dictionary in Python? We’ve covered what dictionaries are in our article here. As there are a couple of ways to merge multiple dictionaries in Python, we’ve put together this article separately to make sure we’ve got everything covered! Merging/Joining Using Dictionary Union … Read more

Home » Articles by: Brad Morton

The Python ord() Function – What it Does and How to Use It

Python ord()

The ord() function returns an integer representation of a Unicode character. Here’s why it does that and how it’s used. Python ord() Function Syntax First, here’s the syntax for the ord() function: ord(CHAR) Note that: CHAR is the single Unicode character you wish to receive the corresponding integer representation of Only a single character is allowed! OK, But Why? The integer returned by ord() is the Unicode code point of the character. It’s a unique number that identifies the character. Unicode represents characters from several languages and includes symbols, emojis, and combinations of all of them. When data is saved … Read more

Home » Articles by: Brad Morton

How to Slice a Dictionary in Python, With Examples

Python Dictionary slice()

We’ve covered how to use the slice function to slice strings, tuples, lists, and other sequences. This tutorial will show you how to slice dictionaries, with examples. Dictionaries Not sure what a dictionary is in the Python programming language? Get up to speed with our article here. The slice() Function and the islice() Function Check out the full article here on how the slice() function works – we’ve covered it in-depth. Unfortunately, the slice() function built-in to Python does not work with dictionaries. If you do try to use slice() with a dictionary type variable, you will receive the following error: TypeError: … Read more

Home » Articles by: Brad Morton

How to use Comments in JavaScript

JavaScript Comments

This short article will explain how and why you should use comments in JavaScript. First up, how to comment. What is a Comment? A comment in programing is one or more lines of text that aren’t interpreted as programming instructions. Instead, the computer skips them when executing your code, completely ignoring them. Therefore, comments don’t have to conform to any valid syntax. They’re just text that you read, and the computer doesn’t. Single-Line Comments in JavaScript Commenting is easy. How easy? This easy: // This is a comment … Read more

Home » Articles by: Brad Morton

How to Unzip Files in Linux with the unzip Command

Linux unzip

We’ve zipped files from the Linux command line; now, let’s unzip them. This short article will show you how. Zipping Files Zipping files is common parlance for compressing one or more files or directories into a .zip file – a compressed file format. We cover how to do that in this article, so there’s no need to repeat too much of it here. The Unzip Command The unzip command may not be installed on your system by default. If it isn’t, it can be installed on Debian/Ubuntu-based OS by running: … Read more

Home » Articles by: Brad Morton

/etc /bin /etc /dev – Linux Filesystem Directories and What’s in Them

/etc /bin /etc /dev - Linux Directories and What's in Them

If you’re new to the Linux operating system, you might be a bit confused about exactly what is stored where on your hard drive.  Directories like /etc and /bin might seem confusing to you if you’re used to Windows‘ directory structure. This article will tell you what everything is. As an end-user, you’ll probably only need to worry about the actual contents of a few of these directories – /home, /etc/, /var, /srv, /media. The contents of the other directories are mostly managed by package managers (for installing software) and system services … Read more

Home » Articles by: Brad Morton

How to Execute PHP from the Command Line (Bash/Shell)

Execute PHP from the Command Line/Bash

This article will quickly run through the ways PHP can be used from the Bash shell/command line, with examples. PHP is usually used for generating content to be served on the web – but it can also be used from the command line. This is usually done for the purposes of testing or finding out information about the PHP environment – but PHP can also be used for writing command-line scripts (though, again, it’s not really done that frequently – probably because there are better … Read more