import random


def take_sample(population, k):
    """Returns a list of k randomly chosen elements from population."""
    result, n, k = [], k, min(k, len(population))
    result = random.sample(population, k)
    while len(result) < n:
        result += random.sample(population, min(k, n - len(result)))
    return result