Python tutorials

Python: Check if String Contains Substring

In this article, we’ll examine four ways to use Python to check whether a string contains a substring. Each has their own use-cases and pros/cons, some of which we’ll briefly cover here: 1) The in Operator The easiest way to check if a Python string contains a substring is to use the in operator. The in operator is used to check data structures for membership in Python. It returns a Boolean (either True or False) and can be used as […]

Read more

Asynchronous Tasks in Django with Redis and Celery

Introduction In this tutorial I will be providing a general understanding of why celery message queue’s are valuable along with how to utilize celery in conjunction with Redis in a Django application. To demonstrate implementation specifics I will build a minimalistic image processing application that generates thumbnails of images submitted by users. The following topics will be covered: The code for this example can be found on GitHub along with installation and set up instructions if you just want to […]

Read more

Image Recognition in Python with TensorFlow and Keras

Introduction One of the most common utilizations of TensorFlow and Keras is the recognition/classification of images. If you want to learn how to use Keras to classify or recognize images, this article will teach you how. Definitions If you aren’t clear on the basic concepts behind image recognition, it will be difficult to completely understand the rest of this article. So before we proceed any further, let’s take a moment to define some terms. TensorFlow/Keras Credit: commons.wikimedia.org TensorFlow is an […]

Read more

The Python zip() Function

In this article, we’ll examine how to use the built-in Python zip() function. The zip() function is a Python built-in function that allows us to combine corresponding elements from multiple sequences into a single list of tuples. The sequences are the arguments accepted by the zip() function. Any number of sequences can be supplied, but the most common use-case is to combine corresponding elements in two sequences. For example, let’s say we have the two lists below: >>> vehicles = […]

Read more

The Python String strip() Function

In this article, we’ll examine how to strip characters from both ends of a string in Python. The built-in String type is an essential Python structure, and comes with a built-in set of methods to simplify working with text data. There are many situations in which a programmer may want to remove unwanted characters, i.e. strip certain characters, from either the beginning or ending of a string. The most common requirement is to strip whitespace (spaces, tabs, newline characters, etc.) […]

Read more

Predicting Customer Ad Clicks via Machine Learning

Introduction Internet marketing has taken over traditional marketing strategies in the recent past. Companies prefer to advertise their products on websites and social media platforms. However, targeting the right audience is still a challenge in online marketing. Spending millions to display the advertisement to the audience that is not likely to buy your products can be costly. In this article, we will work with the advertising data of a marketing agency to develop a machine learning algorithm that predicts if […]

Read more

Creating and Importing Modules in Python

Introduction In Python, a module is a self-contained file with Python statements and definitions. For example, file.py, can be considered a module named file. This differs from a package in that a package is a collection of modules in directories that give structure and hierarchy to the modules. Modules help us break down large programs into small files that are more manageable. With modules, code reusability becomes a reality. Suppose we have a function that is frequently used in different […]

Read more

Working with PDFs in Python: Inserting, Deleting, and Reordering Pages

This article is the third in a series on working with PDFs in Python: Introduction This article is part three of a little series on working with PDFs in Python. In the previous articles we gave an introduction into reading PDF documents using Python. So far you have learned how to manipulate existing PDFs, and to read and extract the content – both text and images. Furthermore, we have discussed splitting documents into its single pages, as well as adding […]

Read more

Getting Started with Python’s Wikipedia API

Introduction In this article, we will be using the Wikipedia API to retrieve data from Wikipedia. Data scraping has seen a rapid surge owing to the increasing use of data analytics and machine learning tools. The Internet is the single largest source of information, and therefore it is important to know how to fetch data from various sources. And with Wikipedia being one of the largest and most popular sources for information on the Internet, this is a natural place […]

Read more

Concurrency in Python

Introduction Computing has evolved over time and more and more ways have come up to make computers run even faster. What if instead of executing a single instruction at a time, we can also execute several instructions at the same time? This would mean a significant increase in the performance of a system. Through concurrency, we can achieve this and our Python programs will be able to handle even more requests at a single time, and over time leading to […]

Read more
1 138 139 140 141 142 164