# Month: July 2021

## How to Sum the Digits of a Number in Python?

Problem Formulation Given an integer number. How to sum over all digits of this number to compute the crossfoot (cross total)? Consider the following examples: 12 –> 1+2 = 3 123 –> 1+2+3 = 3 244 –> 2+4+4 = 10 981223 –> 9+8+1+2+2+3 = 25 Method 1: sum() with Generator Expression The Python built-in sum(iterable) …

## How to Print Subscript in Python?

Problem Formulation Given two strings x and y. Create a new string xy and print it to the shell. Consider the following examples: INPUT x = ‘hi’ y = ‘finxter’ OUTPUT: hifinxter INPUT x = ‘2’ y = ‘4’ OUTPUT: 24 INPUT x = ‘abc’ y = ‘[1, 2, 3]’ OUTPUT: abc[1, 2, 3] Solution …

## List of Unicode Superscript Characters

Character Description Character U+2070 SUPERSCRIPT ZERO ⁰ U+2071 SUPERSCRIPT LATIN SMALL LETTER I ⁱ U+2074 SUPERSCRIPT FOUR ⁴ U+2075 SUPERSCRIPT FIVE ⁵ U+2076 SUPERSCRIPT SIX ⁶ U+2077 SUPERSCRIPT SEVEN ⁷ U+2078 SUPERSCRIPT EIGHT ⁸ U+2079 SUPERSCRIPT NINE ⁹ U+207A SUPERSCRIPT PLUS SIGN ⁺ U+207B SUPERSCRIPT MINUS ⁻ U+207C SUPERSCRIPT EQUALS SIGN ⁼ U+207D SUPERSCRIPT LEFT …

## How to Print Superscript in Python?

Problem Formulation Given two strings x and y. Create a new string xy and print it to the shell. Consider the following examples: INPUT x = ‘hi’ y = ‘finxter’ OUTPUT: hifinxter INPUT x = ‘2’ y = ‘4’ OUTPUT: 24 INPUT x = ‘abc’ y = ‘[1, 2, 3]’ OUTPUT: abc[1, 2, 3] Solution …

## How to Comment Out a Block of Code in Python?

Problem Formulation Python has two ways to comment out a block of code: The hashtag symbol # tells the Python interpreter to ignore the rest of the line. To manually commenting out a block of code by inserting a hashtag symbol in front of every line is cumbersome. The multi-line string triple quotes ”’…”’ or …

## [Google Interview] Reverse Vowels In A String In Python

Learn how to reverse vowels in a string in Python in this article!

## Python Bitwise Operators [Full Guide + Videos]

Bitwise operators perform operations on the binary (bit) representation of integers. Background: Each integer is first written as a binary number that is a sequence of digits 0 or 1. For example: 0 is written as “0” 1 is written as “1” 2 is written as “10” 3 is written as “11” 4 is written …

## NumPy Broadcasting – A Simple Tutorial

Broadcasting describes how NumPy automatically brings two arrays with different shapes to a compatible shape during arithmetic operations. Generally, the smaller array is “repeated” multiple times until both arrays have the same shape. Broadcasting is memory-efficient as it doesn’t actually copy the smaller array multiple times. Here’s a minimal example: Let’s have a more gentle …

## Python Logical Operators [Blog + Video]

Logical operators work on Boolean values but can be used on integers and other objects as well. Python has three logical operators: and, or, and not. The following table provides a quick overview of Python logical operators: Operator Description Example and Returns True if both operands are True, and False otherwise. (True and True) == …

## [Google Interview] How To Solve The Plus One Problem?

Learn the techniques to solve the plus-one problem and crack your next coding interview!

## An Introduction To Closures and Decorators in Python

Today’s tutorial will introduce two slightly more advanced concepts of closures and decorators in Python. We’ll explain what they are, how each is defined, and where and how they will help in your coding. Nested Functions I’m sure you are all familiar with functions, and some of you may have used, or heard of, nested …

## Python Arithmetic Operators

Arithmetic operators are syntactical shortcuts to perform basic mathematical operations on numbers. Operator Name Description Example + Addition Calculating the sum of the two operands 3 + 4 == 7 – Subtraction Subtracting the second operand from the first operand 4 – 3 == 1 * Multiplication Multiplying the first with the second operand 3 …