<jupyter_start><jupyter_text>1) scrivi una funzione che prenda * una stringa come input * e ritorni "True" se contiene esattamente una "A" * e "False" in caso contrario<jupyter_code>def one_A(stringa):
    if stringa.count("A") == 1:
        return True
    else:
        return False
    
one_A("NNAA|")
def one_complex_A(wort):
    A_count = 0 # initializing counter at 0
    for char in wort:
        if char == "A":
            A_count += 1
    if A_count == 1:
        return True
    else:
        return False

print(one_complex_A("NNNNNN"))
print(one_complex_A("NNNNA"))<jupyter_output>False
True<jupyter_text>2) scrivi un programma che prenda un integer come input dall' user finché l'user non inserisce 0, e restituisce la somma dei numeri precedentemente inseritiWrite a programm* that takes as input an integer    - from the user* until the user inserts 0* it then returns the sum of previously inserted numbers<jupyter_code>user_input = int(input("Please insert and integer. "))
somma = user_input
while user_input != 0:
    user_input = int(input("Please insert and integer. "))
    somma += user_input
print(somma)<jupyter_output>Please insert and integer.  1
Please insert and integer.  2
Please insert and integer.  3
Please insert and integer.  0<jupyter_text>3) definisci un dizionario la se seguenti Key: Ivan, Allegra, Pietro e come valori Lanese, Via, Dilena, dopodiché stampa a schermo il primo valore in lettere maiuscoleDefine a dictionary containing the following keys:    Ivan    Allegra    PietroAnd as keys:    Lanese    Via    DilenaThen print the first value in CAPSI am assuming that he means *first* as used sematnitcally - so the first number which is index 0.<jupyter_code># for fun: generating the dictionary from 2 lists:

first =[ 'Ivan', 'Allegra', 'Pietro']
last = [ 'Lanese', 'Via', 'Dilena',]

names_d = {}

for i in range(len(first)):
    names_d[first[i]]=last[i]
    
names_d

# answering the actual question

# in case i didn't know what the first entry is
keys = names_d.keys() # accessing the keys - method returns a view object.
keylist = list(keys)  # turning view object into list
first_val = keylist[0]
print(first_val.upper())<jupyter_output>IVAN<jupyter_text>4) definisci una funzione ricorsiva per definire il numero di caratteri "A, C, G e T" presenti in una stringa Define a recursive function* to define the number of characters    - "A, C, G e T" in a string.<jupyter_code># def double_zero(li):
#     if len(e) == 0
e = [1,4,8,0,2,3]

def double_0(e):
    if len(e) == 0:
        return 0
    if len(e) == 1 and e[0] != 0:
        return e[0]*2
    if e[0] != 0:
        return e[0]*2, double_0(e[1:])

print(double_0(e))<jupyter_output>(2, (8, (16, None)))
{'fraction_non_alphanumeric': 0.09937430990062569, 'fraction_numerical': 0.016562384983437616, 'mean_word_length': 3.8106194690265487, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 13, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '156597', 'license': 'MIT', 'n_tokens_mistral': 956, 'n_tokens_neox': 938, 'n_words': 335, 'path': 'simple_exercises/previous_exam2.ipynb', 'repo_name': 'ilante/programming_immanuela_englander', 'size': '2717'}