<jupyter_start><jupyter_text>1 - Equal SplitCreate a function that determines whether or not it’s possible to split a pie fairly given these three parameters:  - Total number of slices  - Number of recipients  - How many slices each person gets Form of the function:  - equal_slices(total_ slices, no_recipients, slices_each)Examples:    equal_slices(11, 5, 2) ➞ True    5 people x 2 slices each = 10 slices < 11 slices     equal_slices(11, 5, 3) ➞ False    5 people x 3 slices each = 15 slices > 11 slices    equal_slices(8, 3, 2) ➞ True    equal_slices(8, 3, 3) ➞ False    equal_slices(24, 12, 2) ➞ TrueNotes: - Return True if there are zero people. - It's fine not to use the entire pie. - All parameters are integers<jupyter_code># 1A Answer
def equal_slices(total_slices, no_recipients, slices_each):
    if no_recipients == 0:
        return True
    if (slices_each * no_recipients) > total_slices:
        return False
    else:
        return True
    
# 1B Advanced Answer
def equal_slices(total_slices, no_recipients, slices_each):
    return True if no_recipients * slices_each <= total_slices else False<jupyter_output><empty_output><jupyter_text>2 - Pieces RemainingAdjust the function 'equal_slices' from question_00 to return number of pieces left as well.Examples:    equal_slices(11, 5, 2) ➞ (True, 1)     5 people x 2 slices each = 10 slices < 11 slices     equal_slices(11, 5, 3) ➞ (False,None)     5 people x 3 slices each = 15 slices > 11 slicess    equal_slices(8, 3, 2) ➞ (True, 2)    equal_slices(8, 3, 3) ➞ (False, None)    equal_slices(24, 12, 2) ➞ (True, 0)Notes: - Return (True, total_slices) if there are zero people. - All parameters are integers.<jupyter_code># 2A Answer
def equal_slices(total_slices, no_recipients, slices_each):
    if no_recipients == 0:
        return (True, total_slices)
    if (slices_each * no_recipients) > total_slices:
        return (False, None)
    else:
        remaining = total_slices - (slices_each * no_recipients)
        return (True, remaining)
    
# 2B Advanced Answer
def equal_slices(total_slices, no_recipients, slices_each):
    sol = True if no_recipients * slices_each <= total_slices else False
    remains = total_slices - (no_recipients * slices_each) 
    remains = remains if remains >= 0 else None

    return sol,remains<jupyter_output><empty_output><jupyter_text>3 - Count Unique String CharactersGiven two strings, create a function that returns the total number of unique characters from the combined string.Examples:    count_unique_chars("apple", "play") ➞ 5    "appleplay" has 5 unique characters:  "a", "e", "l", "p", "y"    count_unique_chars("sore", "zebra") ➞ 7    count_unique_chars("a", "soup") ➞ 5Notes: - Careful with empty strings - All characters will be lowercase.<jupyter_code># 3A Answer
def count_unique_chars(string_1, string_2):
    #if string_1 or string_2 == "":

    list1 = [char for char in string_1]
    list2 = [char for char in string_2]
    uniq = list1
    for char in list2:
        if char not in list1:
            uniq.append(char)
    count_uniq = len(uniq)
    return count_uniq

# 3B Advanced Answer
def count_unique_chars(string_1, string_2):
    return len(set(string_1 + string_2))<jupyter_output><empty_output><jupyter_text>4 - Reverse + Lowercase String CharactersCreate a function that takes a string of lowercase characters and returns that string reversed and in upper case.Examples:    reverse_capitalize("abc") ➞ "CBA"    reverse_capitalize("hellothere") ➞ "EREHTOLLEH"    reverse_capitalize("input") ➞ "TUPNI"<jupyter_code># 4A Answer
def reverse_capitalize(string):
    upper = string.upper()
    reverse = upper[::-1]
    return reverse

# 4B Advanced Answer
def reverse_capitalize(string):
    return string[::-1].upper()<jupyter_output><empty_output><jupyter_text>5 - Division BooleanCreate a function that takes an integer and returns True if it's divisible by 100, otherwise return False.Examples:    divisible(1) ➞ False    divisible(1000) ➞ True    divisible(100) ➞ True<jupyter_code># 5A Answer
def divisible(integer):
    if integer % 100 == 0:
        return True
    else:
        return False
    
# 5B Advanced Answer
def divisible(integer):
    return True if integer % 100 == 0 else False<jupyter_output><empty_output><jupyter_text>6 - List of String and NumbersCreate a function that takes a list of strings and integers,     and filters out the list so that it returns a list of integers only.Examples:    filter_list([1, 2, 3, "a", "b", 4]) returns [1, 2, 3, 4]    filter_list(['A', 0, 'Edabit', 1729, 'Python', '1729']) returns [0, 1729]Notes:- Function always returns list<jupyter_code># 6A Answer
def filter_list(lst):
    return [i for i in lst if isinstance(i, int)]

# 6B Advanced Answer<jupyter_output><empty_output><jupyter_text>7 - AverageCreate a function that returns the mean of all digits.Example:    mean(42) ➞ 3.0    mean(12345) ➞ 3.0    mean(666) ➞ 6.0Notes:- Function should always return float<jupyter_code># 7A Answer
def mean(digits):
    digit_list = list(map(int, str(digits)))
    return sum(digit_list)/len(digit_list)

# 7B Advanced Answer<jupyter_output><empty_output><jupyter_text>8 - CountWrite a function that takes a string and calculates the number of letters and digits within it. Return the result in a dictionary.Examples:    count_all("Hello World") ➞ { "LETTERS":  10, "DIGITS": 0 }    count_all("H3ll0 Wor1d") ➞ { "LETTERS":  7, "DIGITS": 3 }    count_all("149990") ➞ { "LETTERS": 0, "DIGITS": 6 }Notes:- Tests contain only alphanumeric characters.- Spaces are not letters.- All tests contain valid strings.- The function should return dictionary<jupyter_code># 8A Answer
def count_all(string):
    letters = 0
    digits = 0
    count = {}
    for char in string:
        if char.isnumeric():
            digits += 1
        elif char.isalpha():
            letters += 1
        else:
            pass # darn space was messing with me
    count['LETTERS'] = letters
    count['DIGITS'] = digits
    return count

# 8B Advanced Answer<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09707776126795443, 'fraction_numerical': 0.0316988608221892, 'mean_word_length': 3.865863453815261, 'pattern_counts': {'":': 7, '<': 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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '287932', 'license': 'MIT', 'n_tokens_mistral': 2218, 'n_tokens_neox': 1984, 'n_words': 678, 'path': 'Python Fundamentals/.ipynb_checkpoints/Technical Python Tests-checkpoint.ipynb', 'repo_name': 'robynmundle/data_science', 'size': '6057'}