How to Reverse a Range in Python?

Summary: Use negative step in the range() function to reverse the given sequnce as: range(start, stop, -step). Another workaround is to apply the reversed() function to the given range to reverse it as: reversed(range(start, stop)). Problem: Given a range/sequence of numbers, how will you reverse the range? Example: Given:# Given rangefor i in range(1, 6): … Read more

Python – How to Find the Longest Substring in Alphabetical Order?

Programming Challenge πŸ’¬ Challenge: Given a Python string. Find the longest substring for which holds that all of its characters are in alphabetical order so that the first character comes earlier in the alphabet than the second character, and so on. Here are three examples: You get the point. πŸ™‚ Next, I’ll show you three … Read more

How to Check Python Version in Colab?

To check your Python version in Google’s Colab, type !python ‐‐version using the exclamation mark ! operator in your Jupyter Notebook cell and click on the “Run” icon. After a couple of seconds an output like Python 3.9 will appear, depending on the version you’ve installed. In Jupyter notebooks, the exclamation mark ! executes commands … Read more

Solidity by Example – Understanding Modular Contracts

This article continues on the Solidity Smart Contract Examples series and implements an example of a modular contract checking that the balances being sent between the addresses comply with the requirements (docs). We’ll first lay out the entire smart contract example without the comments for readability and development purposes. Then we’ll dissect it part by … Read more

How to Change File Permissions in Python?

Problem Formulation and Solution Overview When a new file or folder is created, it comes with its own set of default permissions. From time to time, you will need to adjust these permissions. To follow this article, download the finxter.csv file and move this file to the current working directory. What are File Permissions? File … Read more

TensorFlow vs PyTorch — Who’s Ahead in 2023?

Is TensorFlow Better Than PyTorch? Since PyTorch made its way into the machine learning sphere in 2016, loyalists from both camps have sung the praises of their framework of choice.Β  Today, curious minds such as yourself are looking through page after page to find out which one is worth your valuable time and effort. Both … Read more

How to Flatten a NumPy Array

Flatten to a 1D NumPy Array To flatten any NumPy array to a one-dimensional array, use the array.flatten() method that returns a new flattened 1D array. Here’s a simple example: Flatten NumPy Array Along Axis with reshape() To “flatten” a NumPy array along an axis, it’s often better to use the array.reshape() function. You can … Read more