<jupyter_start><jupyter_text>2018-09-18 - Rappels sur le langage pythonNotebooks écrit durant la séance du 18 septembre 2018 à propos du langage Python.<jupyter_code>a = 4
a
print(a)
b = 5
c = a + b
c
entier = 1
reel = 4.5
chaine = "45"
chaine = '45'
chaine = """
fgfgqlibufliszqb
"""
chaine
print(chaine)
couple = (4, 5)
couple
nuplet = (4, 6, 7, 'e')
nuplet
liste = [4, 6, 7, 'e']
liste
nuplet[1]
liste[1]
nuplet[1] = 5
liste[1] = 5
liste
dico = {'e': 4}
dico
dico['e']
dico[0]  ##
dico[0] = 5
dico
dico['lirbfvvbfsjq'] = 'lfvlkjqslkjdf'
dico
dico[(4,5)] = 5
dico
dico[ [4,6] ] = 6
texte = "llmmaab"
dico = {}
for c in texte:
    if c in dico:
        print('+1')
        dico[c] = dico[c] + 1
    elif c == 'l':
        print('+2')
        dico[c] = 0.5
    else:
        print('+3')
        dico[c] = 1
    print(c, dico)
dico
def fonction_histogramme(texte):
    dico = {}
    for c in texte:
        if c in dico:
            dico[c] = dico[c] + 1
        elif c == 'l':
            dico[c] = 0.5
        else:
            dico[c] = 1
    return dico

fonction_histogramme('eriuhgier')
dico = fonction_histogramme('eriuhgier')
print(dico['e'])<jupyter_output>2
{'fraction_non_alphanumeric': 0.1620926243567753, 'fraction_numerical': 0.05060034305317324, 'mean_word_length': 2.624223602484472, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '475392', 'license': 'MIT', 'n_tokens_mistral': 579, 'n_tokens_neox': 541, 'n_words': 137, 'path': '_doc/notebooks/notebook_eleves/2018-2019/2018-09-18_rappels_python.ipynb', 'repo_name': 'Jerome-maker/ensae_teaching_cs', 'size': '1166'}