How to Stop a For Loop in Python

Python provides three ways to stop a for loop: The for loop ends naturally when all elements have been iterated over. After that, Python proceeds with the first statement after the loop construct. The keyword break terminates a loop immediately. The program proceeds with the first statement after the loop construct. The keyword continue terminates … Read more

If-Then-Else in One Line Python

Quick answer: How to put a simple if-then-else statement in one line of Python code? To put an if-then-else statement in one line, use Python’s ternary operator x if c else y. This returns the result of expression x if the Boolean condition c evaluates to True. Otherwise, the ternary operator returns the alternative expression … Read more

Python One Line Ternary

The most basic ternary operator x if c else y consists of three operands x, c, and y. It is an expression with a return value. The ternary operator returns x if the Boolean expression c evaluates to True. Otherwise, if the expression c evaluates to False, the ternary operator returns the alternative y. Ternary … 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: string: ‘helloworld’, longest substring: ‘ellow’ string: ‘abcde’, longest substring: ‘abcde’ … Read more

How to Install the Solidity Compiler via Source Code Compilation?

In this article, we’ll produce, i.e., compile a Solidity compiler from its source code. Platform compilation is not an operation regular computer users explicitly do very often, if ever. However, in some unusual situations, we need specific software in terms of its (previous) version, or it should run in our exotic environment, etc. Regardless of … Read more

Tensors: The Vocabulary of Neural Networks

In this article, we will introduce one of the core elements describing the mathematics of neural networks: tensors. 🧬 Although typically, you won’t work directly with tensors (usually they operate under the hood), it is important to understand what’s going on behind the scenes. In addition, you may often wish to examine tensors so that … Read more