Month: June 2021

How to Limit Floats to Two Decimal Points in Python?

Introduction Problem Formulation: Given a floating-point value. How to limit it to two decimal places in Python? Example: Let’s have a look at a program where you have to calculate the value of pi. Output: Perfect! pi yields you a value = 3.141592653589793. But, what if you need the value of pi only up to …

How to Limit Floats to Two Decimal Points in Python? Read More »

Division in Python

The double-frontslash // operator performs integer division and the single-frontslash / operator performs float division. An example for integer division is 40//11 = 3. An example for float division is 40/11 = 3.6363636363636362. A crucial lesson you need to master as a programmer is “division in Python”. What does it mean to divide in Python? …

Division in Python Read More »

A RegEx to Match Bitcoin Addresses

What regular expressions can be used to match Bitcoin addresses? A regular expression for validating Bitcoin addresses must check that the string is 26-35 characters long, start with “1” or “3” or “bc1” consists of uppercase or lowercase alphabetic and numeric characters, and ensure it doesn’t contain ambiguous characters. Not allowed are the uppercase letter …

A RegEx to Match Bitcoin Addresses Read More »