Home » 2021

Formatting Numbers with number_format() in PHP [Examples]

PHP Number Format

This article will explain how to use the PHP number_format() function, with some helpful examples. Different regions use different number formatting – Some countries, including the UK, USA, Australia, and New Zealand, use a comma (,) to separate thousands when writing large numbers and use a period (.) as a decimal separator. Your computer most likely uses the same formatting when storing number values in a database. However, some countries, like Germany, use a period as the thousands separator and a comma as the decimal separator. Others … Read more

Categories PHP

Home » 2021

Using PHP unset Function to Destroy a Variable, With Examples

PHP unset()

Here’s a short article on a useful PHP feature – the unset construct allows you to destroy a variable, making it unavailable for use. There are a few reasons why you might want to unset a variable: Making sure you don’t accidentally use a variable you don’t want to use in a certain context or scope Cleaning up variables after a loop Make a global variable unavailable within a function or scope Remove an element from an Array Remove an object attribute Read on to see how it’s done. … Read more

Categories PHP

Home » 2021

Multi-Line Comment Blocks in Python – HowTo, With Examples

Python multi-line comment block

This short article will show you how to use comments in Python, including multi-line comments. 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 Python Comments in Python are any line that starts with a # (hash) character. # This … Read more

Home » 2021

Scopes & Global Variables in Python – Explained

Python Scopes & Global Variables

This article will explain and demonstrate scopes in Python – including the global scope and how to declare global variables. What is a Scope? As you move towards building more complex Python applications, you’ll be using functions, loops, try/except statements for error handling, and other more advanced constructs. Which variables are available within each of these constructs is defined by the variable’s scope. The scope is where the variable is available within your program. Different variables have different scopes, and totally distinct/separate variables in different scopes can share … Read more

Home » 2021

Catch Errors/Exceptions in Python with try/except [Examples]

Python try/except to Catch Errors

This article will show you how to use the try/except/finally statements. What are Errors/Exceptions A computer program will produce an error, also known as an exception, when something goes wrong. This could be due to mistyped programming commands (syntax errors) or because the application encountered something unexpected – be it bad user input or a logical condition that can’t be met. When something goes wrong, an exception/error will be thrown – which will usually result in the application stopping and the error being displayed so that it can be found and fixed. … Read more

Home » 2021

How to Write to a Text File in Python

Python Write File

This article will show you how to write to a file in the Python programming Language – examples included! All files are, essentially, text files. Data is formatted and stored in various ways – comma-separated values for spreadsheets (CSV), plain text for text files (TXT), all the way to complex image formats for storing documents and images like PDF and JPG files. Once the program you are building is up and running, you’ll want to be able to save the output it produces – so … Read more

Home » 2021

Linux for Kids – Distributions, Fun Tools, Games & Learning

Linux for Kids

Want to keep the kids busy over the holidays? Get them interested in computing. It’ll keep them busy for the rest of their lives. Computing is a huge field that covers many different subjects and skills – programming, digital art, music-making, engineering – and understanding computing concepts is increasingly important, and it opens the way for learning about just about anything else one might want to learn. A computer can’t just be a tablet playing youtube videos – kids need to be able to understand … Read more

Home » 2021

HEREDOC (Here Documents) in Bash and Linux Shell – Tutorial

Bash Heredoc

This article will show you how to use a Heredoc (Here Document) in Bash/Shell scripts to work with multi-line text. Heredocs are most useful for accepting multi-line input- the user can enter a line of text, press enter, then enter the next line, and so on. It can also be used to define multi-line text in scripts. It can also send multiple commands into an interactive program – this will be shown in the examples later. The examples in this article will work in both … Read more

Home » 2021

Check Disk Health in Linux/Ubuntu [How To / Guide]

Linux Check Disk

Concerned that you have a failing hard drive? Make a backup. Then, use these Linux tools to check your disk/drive. Not concerned that you have a failing drive? Back up anyway. It could be failing, and you don’t know it. Or it could get stolen. Or a meteorite could hit it. Back. Up. Your. Files. What is SMART? S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) is the system most hard disks use to report their health to the installed system. This information can be queried to find out whether a drive is … Read more

Home » 2021

Using the printf Command in Bash/Shell, With Examples

Bash printf Command

This article will show you some practical examples for using the printf command in the Bash/Shell on Linux. The printf command outputs text much like the echo command does – but it allows for more control over the output formatting. It’s a useful tool for generating your own formatted text output – especially if you need to embed variables in text, include newlines, align and format text, and even display converted values. printf Syntax The printf command has the following syntax: printf [-v var] format [arguments]… Note that: The -v option … Read more