def convert_bytes(num):
    """Function to convert bytes to  KB, MB, GB, TB.

    :param num: number of bytes
    :type num: int
    :return: converted number
    :rtype: str
    """
    for x in ['bytes', 'KB', 'MB', 'GB', 'TB']:
        if num < 1024.0:
            return '%3.1f %s' % (num, x)
        num /= 1024.0
