<jupyter_start><jupyter_text>Assignment Questions  Basic assignments1. Write a function that computes the factorial for an inputted number.<jupyter_code>def factorial(n):
    if n == 0 or n == 1:
        return 1
    return n * factorial(n - 1)<jupyter_output><empty_output><jupyter_text>2. Write a function that determines whether or not an inputted number is prime, and then prints `'The number you inputted is a prime/ not a prime number.'` depending on what your script finds (note that this means putting a `print` in front of the function when testing it will be redundant for this case).<jupyter_code>def basic_prime_test(n):
    if n == 1 or n == 2 or n == 3:
        return True
    if n % 2 == 0:
        return False
    for i in range(2, n):
        if n == i:
            return True
        if n % i == 0:
            return False
    return True
assert basic_prime_test(1)
assert basic_prime_test(2)
assert basic_prime_test(3)
assert not basic_prime_test(4)
assert basic_prime_test(5)
assert not basic_prime_test(6)
assert basic_prime_test(7)
assert not basic_prime_test(8)
assert not basic_prime_test(9)
def is_prime(n):
    if basic_prime_test(n):
        return 'The number you inputted is a prime number.'
    else:
        return 'The number you inputted is not a prime number.'
assert 'The number you inputted is a prime number.' == is_prime(3)
assert 'The number you inputted is not a prime number.' == is_prime(4)<jupyter_output><empty_output><jupyter_text>Advanced assignments1. Write a function that counts the number of words in an inputted string, where we consider words to be separated by spaces.<jupyter_code>def word_count(string):
    return len(string.split(' '))<jupyter_output><empty_output><jupyter_text>2. Write a function that counts the number of words in an inputted string, where we consider words to be separated by a specified delimiter (so your function should accept two arguments, one for the string and one for the delimiter) and a space is defined as the default delimiter.<jupyter_code>def word_count(string, delimiter=' '):
    return len(string.split(delimiter))<jupyter_output><empty_output><jupyter_text>3. Write a function that takes in a string, and returns a list that holds the length of each word in the phrase, separated by an inputted delimiter (so you're function should accept two arguments again). Make a space the default delimiter like you did in 2. For example, if the arguments to your function were This is a test string (and nothing else), your function should return `[4, 2, 1, 4, 6]`. Go ahead and don't worry about removing punctuation (you can include it in the word length - e.g. "this." has five letters, if we count the period).<jupyter_code>def word_length(string, delimiter=' '):
    return list(map(lambda w: len(w), string.split(' ')))
assert [3, 3, 5] == word_length("one two three")<jupyter_output><empty_output><jupyter_text>4. Write a function that returns all the prime numbers up to an inputted number (Hint: It might be helpful to use/modify the prime function you wrote earlier).<jupyter_code>def all_primes(n):
    return [i for i in range(n + 1) if basic_prime_test(i)]
assert [1, 2, 3, 5, 7, 11, 13, 17] == all_primes(17)<jupyter_output><empty_output><jupyter_text>5. Write a function that takes in a list of numbers, as well as an additional number (i.e. two arguments), and returns a list of yes or no depending on whether each number in the list is divisible by the second number. For example, if I input `[10, 25, 36, 12, 20]` as the list of numbers, and 5 as the additional number, your function should return `['yes', 'yes', 'no', 'no', 'yes']`.<jupyter_code>def is_devidable(dividents, divisor):
    return list(map(lambda d: 'yes' if d % divisor == 0 else 'no', dividents))
assert ['yes', 'yes', 'no', 'no', 'yes'] == is_devidable([10, 25, 36, 12, 20], 5)<jupyter_output><empty_output><jupyter_text>6. Write a function that takes in a list of strings, as well as an inputted letter (which looks like a string with a single character), and returns a list of only those strings from the input list that end with that letter. For example, if I input `['I', 'am', 'in', 'love', 'with', 'Python']` as the list of strings, and n as the inputted letter, your function should return `['in', 'Python']`.<jupyter_code>def words_which_end_with(words, char):
    return list(filter(lambda word: word.endswith(char), words))
assert ['in', 'Python'] == words_which_end_with(['I', 'am', 'in', 'love', 'with', 'Python'], 'n')<jupyter_output><empty_output><jupyter_text>7. Write a function that takes in a list of strings, as well as an inputted substring (i.e. another string), and returns a list of the indices of the strings that contain that inputted substring. For example, if I input `['This', 'is, 'an' , 'example']` as the list of strings, and is as the substring, your function should return `[0, 1]`.<jupyter_code>def contain_substrings(strings, substring):
    return [index for index, word in enumerate(strings) if word.find(substring) > -1]
assert [0, 1] == contain_substrings(['This', 'is', 'an' , 'example'], 'is')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10289826881929585, 'fraction_numerical': 0.01595020424042015, 'mean_word_length': 4.700665188470066, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '297506', 'license': 'Apache-2.0', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1543, 'n_words': 686, 'path': 'nf-datascience-day005_salihovic_functions_callenge.ipynb', 'repo_name': 'tigerarcades/-nf-datascience-day005_assignments_week001', 'size': '5141'}