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.

  • Pad number

    Pads a given number to the specified length.

    Python, String · Nov 2, 2020

  • Byte size of string

    Returns the length of a string in bytes.

    Python, String · Nov 2, 2020

  • Capitalize every word

    Capitalizes the first letter of every word in a string.

    Python, String · Nov 2, 2020

  • Factorial

    Calculates the factorial of a number.

    Python, Math · Sep 15, 2020

  • Repeat string

    Generates a string with the given string value repeated n number of times.

    Python, String · Nov 2, 2020

  • Binomial coefficient

    Calculates the number of ways to choose k items from n items without repetition and without order.

    Python, Math · Nov 2, 2020

  • Degrees to radians

    Converts an angle from degrees to radians.

    Python, Math · Nov 2, 2020

  • Radians to degrees

    Converts an angle from radians to degrees.

    Python, Math · Nov 2, 2020

  • Number to binary

    Returns the binary representation of the given number.

    Python, Math · Oct 7, 2020

  • Number to hex

    Returns the hexadecimal representation of the given number.

    Python, Math · Oct 9, 2020