Start of main content## Python 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.

### List intersection

Python, List

Returns a list of elements that exist in both lists.

### List is contained in other list

Python, List

Checks if the elements of the first list are contained in the second one regardless of order.

### Last list element

Python, List

Returns the last element in a list.

### Palindrome

Python, String

Checks if the given string is a palindrome.

### List union

Python, List

Returns every element that exists in any of the two lists once.

### Add days to date

Python, Date

Calculates the date of

`n`

days from the given date.### Clamp number

Python, Math

Clamps

`num`

within the inclusive range specified by the boundary values.### Number in range

Python, Math

Checks if the given number falls within the given range.

### Number is prime

Python, Math

Checks if the provided integer is a prime number.

### Pad number

Python, String

Pads a given number to the specified length.

### Byte size of string

Python, String

Returns the length of a string in bytes.

### Capitalize every word

Python, String

Capitalizes the first letter of every word in a string.

### Repeat string

Python, String

Generates a string with the given string value repeated

`n`

number of times.### Factorial

Python, Math

Calculates the factorial of a number.

### Binomial coefficient

Python, Math

Calculates the number of ways to choose

`k`

items from`n`

items without repetition and without order.