Solidity Control Structures

In this article, we’ll take a closer look at control structures in Solidity. It’s part of our long-standing tradition to make this (and other) articles a faithful companion, or a supplement to the official Solidity documentation. You can watch our explainer video here: So far, we’ve been observing various areas of Solidity, with units and … Read more

How to Convert a NumPy Array to a Python List? (1D, 2D, 0D)

In this post, we will explore simple methods to convert NumPy arrays to lists. For example, we can utilize the Python function list() or the NumPy array method tolist().Β  Both ways are similar, but there are some differences to consider to choose the right one for each application.  Python Function list() The function list() accepts … Read more

“is” vs “==” Python Identity and Equality

πŸ’¬ Question: What is the difference between Python’s is and == operators? Answer The Python “==” operator compares equality of values whereas the Python “is” operator compares identity of objects, i.e., do the two operands point to the same object in memory. For example, the expression [1, 2, 3] == [1, 2, 3] returns True … Read more

Using PyTorch to Build a Working Neural Network

In this article, we will use PyTorch to build a working neural network. Specifically, this network will be trained to recognize handwritten numerical digits using the famous MNIST dataset. The code in this article borrows heavily from the PyTorch tutorial “Learn the Basics”. We do this for several reasons. Knowledge Background This article assumes the … Read more

Format Integer List to Hex String – Six Pythonic Ways

Problem Formulation πŸ’¬ Question: How to create a string of hex digits from a list of integers (0–255) so that each hex digit consists of two digits such as “00”, “01”, …, “fe”, “ff”? Here’s an example input/output pair: In: [0, 1, 2, 3, 255, 254, 253] Out: ‘00010203fffefd’ Method 1: Bytearray The easiest way … Read more

Python | Split String by Length

Summary: You can split a string by length by slicing the string into chunks of equal lengths. The indices to slice the string can be deduced using a list comprehension. Minimal Example: Problem Formulation πŸ“œProblem: Given a string, how will you split the string by length? Here’s a related question asked in stack overflow that … Read more

7 Pythonic Ways to Copy a Dictionary

Problem Formulation and Solution Overview This article will show you how to copy a Dictionary in Python 7 different ways. To make it more interesting, we have the following running scenario: Mr. Smith, a High School Math Teacher, has developed an exciting way to grade multiple-choice exams. He has designed a Dictionary with the exam … Read more

Python decode()

This tutorial explains the Python decode() method with arguments and examples. Before we dive into the Python decode() method, let’s first build some background knowledge about encoding and decoding so you can better understand its purpose. πŸ‘‡ Encoding and Decoding – What Does It Mean? Programs must handle various characters in several languages. Application developers … Read more

Solidity: Bytes/String Members | Error Handling | Contract Functions

Continuing on the previous article concerning address member types and type information, we’ll learn about It’s part of our long-standing tradition to make this (and other) articles a faithful companion, or a supplement to the official Solidity documentation. Members of bytes and string Two practical member functions are available for concatenating a variable number of … Read more

Solidity – Members of Address Types and Type Information

Continuing on the previous article concerning units and globally available variables, we’ll learn about members of address types and type information. It’s part of our long-standing tradition to make this (and other) articles a faithful companion, or a supplement to the official Solidity documentation. ▢️ Play: Feel free to watch our article explainer video while … Read more

Python Int to Hex | String Formatting

πŸ’¬ Question: How to use Python’s string formatting capabilities — f-strings, percentage operator, format(), string.format() — to convert an integer to a hexadecimal string? Lowercase Solution without ‘0x’ Prefix You can convert an integer my_int to a simple lowercase hex string without ‘0x’ prefix by using any of the four string formatting variants—all based on … Read more

How to Export MySQL to a CSV (Dashboard+Python)

This article shows you how to export a Database Table to a CSV file using MySQL. ℹ️ SQL, an acronym for Structured Query Language, is the language of the Database! This standardized language is used to manage databases, tables and the data they hold. A must-have in the coding world. This language allows coders to … Read more