# Python Math Snippets

The Python snippet collection contains helper functions for Python 3.6. It includes utilities for most common data types, such as primitivies, lists, dictionaries and date objects.

• Python ·

### Hex to RGB

Converts a hexadecimal color code to a tuple of integers corresponding to its RGB components.

• Python ·

### Digitize number

Converts a number to a list of digits.

• Python ·

### Find parity outliers

Finds the items that are parity outliers in a given list.

• Python ·

### RGB to hex

Converts the values of RGB components to a hexadecimal color code.

• Python ·

### Sum of powers

Returns the sum of the powers of all the numbers from `start` to `end` (both inclusive).

• Python ·

### Integer to roman numeral

Converts an integer to its roman numeral representation. Accepts value between `1` and `3999` (both inclusive).

• Python ·

### Mapped list average

Calculates the average of a list, after mapping each element to a value using the provided function.

• Python ·

### Geometric progression

Initializes a list containing the numbers in the specified geometric progression range.

• Python ·

### Max list value based on function

Returns the maximum value of a list, after mapping each element to a value using the provided function.

• Python ·

### Median

Finds the median of a list of numbers.

• Python ·

### Min list value based on function

Returns the minimum value of a list, after mapping each element to a value using the provided function.

• Python ·

### Sum list based on function

Calculates the sum of a list, after mapping each element to a value using the provided function.

• Python ·

### N max elements

Returns the `n` maximum elements from the provided list.

• Python ·

### N min elements

Returns the `n` minimum elements from the provided list.

• Python ·

### Prime factors of number

Finds and returns the list of prime factors of a number.

• Python ·

### Reverse number

Reverses a number.

• Python ·

### Greatest common divisor

Calculates the greatest common divisor of a list of numbers.

• Python ·

### Hamming distance

Calculates the Hamming distance between two values.

• Python ·

### Least common multiple

Returns the least common multiple of a list of numbers.

• Python ·

### Powerset

Returns the powerset of a given iterable.

• Python ·

### Weighted average

Returns the weighted average of two or more numbers.

• Python ·

### Index of max element

Returns the index of the element with the maximum value in a list.

• Python ·

### Arithmetic progression

Generates a list of numbers in the arithmetic progression starting with the given positive integer and up to the specified limit.

• Python ·

### Map number to range

Maps a number from one range to another range.

Start typing a keyphrase to see matching snippets.