<jupyter_start><jupyter_text>1. Create a checker board generator, which takes as inputs n and 2 elements to generate an n x n checkerboard with those two elements as alternating squares.Exampleschecker_board(2, 7, 6) ➞ [ [7, 6], [6, 7] ]checker_board(3, "A", "B") ➞ [ ["A", "B", "A"], ["B", "A", "B"], ["A", "B", "A"] ]checker_board(4, "c", "d") ➞ [ ["c", "d", "c", "d"], ["d", "c", "d", "c"], ["c", "d", "c", "d"], ["d", "c", "d", "c"] ]checker_board(4, "c", "c") ➞ "invalid"<jupyter_code>def checker_board(dimensions, char1, char2):
    matrix = []
    chars = [char1, char2]
    if char1 == char2:
        return "invalid"
    for i in range(0, dimensions):
        row = []
        for j in range(0, dimensions):
            if i%2 == 0:
                if j%2 == 0:
                    row.append(chars[0])
                else:
                    row.append(chars[1])
            else:
                if j%2 == 0:
                    row.append(chars[1])
                else:
                    row.append(chars[0])
        matrix.append(row)
    return matrix

print(checker_board(2, 7, 6))
print(checker_board(3, "A", "B"))
print(checker_board(4, "c", "d"))
print(checker_board(4, "c", "c"))<jupyter_output>[[7, 6], [6, 7]]
[['A', 'B', 'A'], ['B', 'A', 'B'], ['A', 'B', 'A']]
[['c', 'd', 'c', 'd'], ['d', 'c', 'd', 'c'], ['c', 'd', 'c', 'd'], ['d', 'c', 'd', 'c']]
invalid<jupyter_text>2. A string is an almost-palindrome if, by changing only one character, you can make it a palindrome. Create a function that returns True if a string is an almost-palindrome and False otherwise.Examples* almost_palindrome("abcdcbg") ➞ True Transformed to "abcdcba" by changing "g" to "a".* almost_palindrome("abccia") ➞ True  Transformed to "abccba" by changing "i" to "b".* almost_palindrome("abcdaaa") ➞ False Can't be transformed to a palindrome in exactly 1 turn<jupyter_code>def almost_palindrome(string:str) -> bool:
    count = 0
    for i in range(0, len(string)//2):
        if string[i] != string[len(string) - i -1]:
            count += 1
    if count == 1:
        return True
    return False

print(almost_palindrome("abcdcbg"))
print(almost_palindrome("abcacia"))
print(almost_palindrome("abcdaaa"))<jupyter_output>True
True
False<jupyter_text>3. Create a function that finds how many prime numbers there are, up to the given integer.Examples* prime_numbers(10) ➞ 4  2, 3, 5 and 7* prime_numbers(20) ➞ 8  2, 3, 5, 7, 11, 13, 17 and 19* prime_numbers(30) ➞ 10  2, 3, 5, 7, 11, 13, 17, 19, 23 and 29<jupyter_code>import math
def prime_numbers(n):
    count = 0
    for i in range(2,n+1):
        for j in range(2,i//2+1):
            if i % j == 0:                
                break
        else:
            count += 1
    return count

print(prime_numbers(10))
print(prime_numbers(20))
print(prime_numbers(30))<jupyter_output>4
8
10<jupyter_text>4. If today was Monday, in two days, it would be Wednesday.Create a function that takes in a list of days as input and the number of days to increment by. Return a list of days after n number of days has passed.Examplesafter_n_days(["Thursday", "Monday"], 4) ➞ ["Monday", "Friday"]after_n_days(["Sunday", "Sunday", "Sunday"], 1) ➞ ["Monday", "Monday", "Monday"]after_n_days(["Monday", "Tuesday", "Friday"], 1) ➞ ["Tuesday", "Wednesday", "Saturday"]<jupyter_code>def after_n_days(days:list, n:int)-> list:
    week = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
    result = []
    for day in days:
        index = week.index(day)
        new_index = int((index + n) % 7)
        result.append(week[new_index])
    return result

print(after_n_days(["Thursday", "Monday"], 4))
print(after_n_days(["Sunday", "Sunday", "Sunday"], 1) )
print(after_n_days(["Monday", "Tuesday", "Friday"], 1))<jupyter_output>['Monday', 'Friday']
['Monday', 'Monday', 'Monday']
['Tuesday', 'Wednesday', 'Saturday']<jupyter_text>5. You are in the process of creating a chat application and want to add an anonymous name feature. This anonymous name feature will create an alias that consists of two capitalized words beginning with the same letter as the users first name.Create a function that determines if the list of users is mapped to a list of anonymous names correctly.Examplesis_correct_aliases(["<NAME>.", "<NAME>.", "<NAME>."], ["Amazing Artichoke", "Hopeful Hedgehog", "Marvelous Mouse"]) ➞ Trueis_correct_aliases(["<NAME>.", "<NAME>.", "<NAME>.", "<NAME>."], ["Reassuring Rat", "Peaceful Panda", "Fantastic Frog", "Notable Nickel"]) ➞ Trueis_correct_aliases(["Beth T."], ["Brandishing Mimosa"]) ➞ False<jupyter_code>def is_correct_aliases(names:list, aliases:list) -> bool:
    for i in range(len(names)):
        char = names[i][0]
        for word in aliases[i].split(' '):
            if not word.startswith(char):
                return False
    return True

print(is_correct_aliases(["<NAME>.", "<NAME>.", "<NAME>."], ["Amazing Artichoke", "Hopeful Hedgehog", "Marvelous Mouse"]))
print(is_correct_aliases(["<NAME>.", "<NAME>.", "<NAME>.", "<NAME>."], ["Reassuring Rat", "Peaceful Panda", "Fantastic Frog", "Notable Nickel"]))
print(is_correct_aliases(["Beth T."], ["Brandishing Mimosa"]))<jupyter_output>True
True
False
StarcoderdataJupyterStructuredCleanDedup