<jupyter_start><jupyter_text>CMPS3660 - Project0This assignment is intended to ensure that you are able to edit and submit Jupyter Notebooks. The goal is to write a function to count the frequency of different characters in a given string. For example: character_frequency('google') should return a `dict`: {'g': 2, 'o': 2, 'l': 1, 'e': 1} and then you should add some code to display some summary statistics about some data that you bring in!There are many tutorials on the web that can show you how to use the Python data structures. Quite a few examples at: https://docs.python.org/3/tutorial/datastructures.htmlIf you have any trouble with this at all (and we are sure at least some of you will), don't worry and stop by our office hours.You should edit the function definition below, make sure to press 'Shift + Enter' to execute it, and then execute the two function calls to check that the output is correct.<jupyter_code>def character_frequency(s):
    ret = dict()
    for i in range(len(s)):
        if s[i] in ret:
            ret[s[i]] +=1
        else:
            ret[s[i]] = 1
    return ret
character_frequency('google')
character_frequency('This assignment is intended to ensure that you are able to edit and submit Jupyter Notebooks.')<jupyter_output><empty_output><jupyter_text>Now in the cell below you should create two string variables and inside them put a different quotes (at least 10 words long) from a favorite book, movie, tv show, or any other media.<jupyter_code>movie1 = "You were the chosen one! It was said that you would destroy the Sith, not join them! Bring balance to the force, not leave it in darkness! You were my brother Anakin! I loved you!"
movie2 = "Señores, Les voy a decir quién soy Yo soy <NAME> Mis ojos están en todos lados o sea ustedes no pueden hacer una puta sola mierda en el departamento de Antioquia que yo me entere. Sí, señores. No pueden mover un dedo. Un día, yo voy a ser presidente de la República de Colombia. Y bien, me gano la vida haciendo negocios. Así que pues, fresco. Tranquilo. Uds pueden aceptar mi negocio o aceptar las consecuencias. Plata o pomo Ustedes eligen"<jupyter_output><empty_output><jupyter_text>For each of the above quotes add code below to print out the character frequency and then give a set of summary statistics for each one, specifically the letter(s) that occur the fewest number of times, the letter(s) that occur the most times, and the average count for all the letters. You should display this data neatly.<jupyter_code>def getPercents(data):
    total = sum(data.values())
    print("There were a total of",total,"characters comprising of",len(data),"unique characters.")
    for key in data:
        percent = str(100*data[key]/total)[:4]
        print("\tCharacter '",key,"' had ",data[key]," appeareances and comprised ",percent,"% of the dataset.",sep="")
def analysis(data):
    print("The three most frequent characters were:")
    for i in range(3):
        key = max(data,key = data.get)
        freq = data[key]
        del data[key]
        print("\tThe character '",key,"' appeared ",freq," times.",sep="")
    print("The three least frequent characters were:")
    for i in range(3):
        key = min(data,key = data.get)
        freq = data[key]
        del data[key]
        print("\tThe character '",key,"' only appeared ",freq," times.",sep="")
def overall_analysis(dataArr):
    #merge all data to one dict
    data = dict()
    for dictionary in dataArr:
        for key in dictionary:
            if key in data:
                data[key] += dictionary[key]
            else:
                data[key] = dictionary[key]
    analysis(data.copy())
    getPercents(data.copy())
data1 = character_frequency(movie1)
print("Star Wars' Quote:",data1)
analysis(data1.copy())
data2 = character_frequency(movie2)
print("Narcos' Quote:", data2)
analysis(data2.copy())
print("_______________________________________________\nCombining all of the data\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _")
overall_analysis([data1.copy(),data2.copy()])<jupyter_output>Star Wars' Quote: {'Y': 2, 'o': 15, 'u': 5, ' ': 34, 'w': 4, 'e': 18, 'r': 8, 't': 14, 'h': 8, 'c': 3, 's': 6, 'n': 11, '!': 5, 'I': 2, 'a': 8, 'i': 7, 'd': 5, 'y': 4, 'l': 4, 'S': 1, ',': 2, 'j': 1, 'm': 2, 'B': 1, 'g': 1, 'b': 2, 'f': 1, 'v': 2, 'k': 2, 'A': 1}
The three most frequent characters were:
	The character ' ' appeared 34 times.
	The character 'e' appeared 18 times.
	The character 'o' appeared 15 times.
The three least frequent characters were:
	The character 'S' only appeared 1 times.
	The character 'j' only appeared 1 times.
	The character 'B' only appeared 1 times.
Narcos' Quote: {'S': 2, 'e': 54, 'ñ': 2, 'o': 40, 'r': 16, 's': 28, ',': 5, ' ': 83, 'L': 1, 'v': 5, 'y': 6, 'a': 33, 'd': 20, 'c': 13, 'i': 22, 'q': 5, 'u': 14, 'é': 1, 'n': 24, 'Y': 2, 'P': 2, 'b': 5, 'l': 13, 'E': 2, 'm': 9, 'G': 1, 'M': 1, 'j': 1, 't': 13, 'á': 1, 'p': 11, 'h': 2, 'A': 2, '.': 8, 'í': 3, 'N': 1, 'U': 3, 'R': 1, 'ú': 1, 'C': 1, 'g': 4, 'f': 1, 'T': 1}
The three most frequent characters were[...]
{'fraction_non_alphanumeric': 0.1383523847063461, 'fraction_numerical': 0.026212061489948757, 'mean_word_length': 3.7474275023386343, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '468464', 'license': 'MIT', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1626, 'n_words': 712, 'path': '_projects/project0/Project0.ipynb', 'repo_name': 'M-Sender/cmps3160', 'size': '5096'}