Python tutorials

Tensorflow 2.0: Solving Classification and Regression Problems

After much hype, Google finally released TensorFlow 2.0 which is the latest version of Google’s flagship deep learning platform. A lot of long-awaited features have been introduced in TensorFlow 2.0. This article very briefly covers how you can develop simple classification and regression models using TensorFlow 2.0. Classification with Tensorflow 2.0 If you have ever worked with Keras library, you are in for a treat. TensorFlow 2.0 now uses Keras API as its default library for training classification and regression […]

Read more

List Comprehensions in Python

A list is one of the fundamental data types in Python. Every time you come across a variable name that’s followed by a square bracket [], or a list constructor, it is a list capable of containing multiple items, making it a compound data type. Similarly, it is also a breeze to declare a new list and subsequently add one or more items to it. Let us create a new populated list, for example: >>> new_list = [1, 2, 3, […]

Read more

Serving Files with Python’s SimpleHTTPServer Module

Introduction Servers are computer software or hardware that processes requests and deliver data to a client over a network. Various types of servers exist, with the most common ones being web servers, database servers, application servers, and transaction servers. Widely used web servers such as Apache, Monkey, and Jigsaw are quite time-consuming to set up when testing out simple projects and a developer’s focus is shifted from producing application logic to setting up a server. Python’s SimpleHTTPServer module is a […]

Read more

Creating Command Line Utilities with Python’s argparse

Introduction Most of the user-facing software comes with a visually pleasing interface or via a decorated webpage. At other times, a program can be so small that it does not warrant an entire graphical user interface or web application to expose its functionality to the end-user. In these cases, we can build programs that are accessible via a Command Line Interface, or CLI. In this post, we will explore Python’s argparse module and use it to build a simple command-line […]

Read more

Executing Shell Commands with Python

Introduction Repetitive tasks are ripe for automation. It is common for developers and system administrators to automate routine tasks like health checks and file backups with shell scripts. However, as those tasks become more complex, shell scripts may become harder to maintain. Fortunately, we can use Python instead of shell scripts for automation. Python provides methods to run shell commands, giving us the same functionality of those shells scripts. Learning how to run shell commands in Python opens the door […]

Read more

Encoding and Decoding Base64 Strings in Python

Introduction Have you ever received a PDF or an image file from someone via email, only to see strange characters when you open it? This can happen if your email server was only designed to handle text data. Files with binary data, bytes that represent non-text information like images, can be easily corrupted when being transferred and processed to text-only systems. Base64 encoding allows us to convert bytes containing binary or text data to ASCII characters. By encoding our data, […]

Read more

Merge Sort in Python

Introduction Merge Sort is one of the most famous sorting algorithms. If you’re studying Computer Science, Merge Sort, alongside Quick Sort is likely the first efficient, general-purpose sorting algorithm you have heard of. It is also a classic example of a divide-and-conquer category of algorithms. Merge Sort The way Merge Sort works is: An initial array is divided into two roughly equal parts. If the array has an odd number of elements, one of those “halves” is by one element […]

Read more

Design Patterns in Python

Introduction Design Patterns are reusable models for solving known and common problems in software architecture. They’re best described as templates for dealing with a certain usual situation. An architect might have a template for designing certain kinds of door-frames which he fits into many of his projects, and a software engineer, or software architect, should know templates for solving frequent programming challenges. A good presentation of a design pattern should include: Name Motivating problem Solution Consequences Equivalent Problems If you […]

Read more

Creational Design Patterns in Python

Overview This is the first article in a short series dedicated to Design Patterns in Python. Creational Design Patterns Creational Design Patterns, as the name implies, deal with the creation of classes or objects. They serve to abstract away the specifics of classes so that we’d be less dependent on their exact implementation, or so that we wouldn’t have to deal with complex construction whenever we need them, or so we’d ensure some special instantiation properties. They’re very useful for […]

Read more

Working with Redis in Python with Django

Introduction Data is increasingly becoming a valuable commodity in the current era of technology and this necessitates the optimization of storage and access to this data. There are quite a few notable solutions for the storage of data, including Relational Database Management Systems (RDBMS) such as MySQL and PostgreSQL, which store data in a structured format using rows and columns and the relationships within the data. Apart from RDBMS, there are key-value stores that store data based on unique keys […]

Read more
1 163 164 165 166 167 182