<jupyter_start><jupyter_text>Dictionary<jupyter_code>results = {"Ann":15,"Bob":9,"Calum":19,"Dave":2,"Eve":12}
#prints out all the keys in the dictionary.
print(list(results.keys()))
#prints out all the values in the dictionary
print(list(results.values()))
#print out all the tuples in the form (key,value)
print(list(results.items()))
for key in results:
    print("%s got %d in the exam" %(key,results[key]))
#Direct indexing into the dictionary
print(results["Bob"])
results["Dave"] = 17

print(results)
#To create a new entry into the dictionary, 
#we can simply use the new key as an index into the dictionary and assign it a value.

results["Fred"] = 5
print(results)
# If the key does not exist, an error is caused
print(results["Gail"])
total = 0
for name in results:
    total += results[name]
print("The average mark was %.1f." %(total/len(results)))
# Print out Eve's exam result.

# Change Ann's exam result to 16

# Add Gail to the dictionary. His exam result was 8.

# Update all the exam results to be double their original score.

studentInfo = {"Ann":{"matrix":12543,"email":"<EMAIL>","exams":[21,34,5,14]},
               "Bob":{"matrix":13524,"email":"<EMAIL>","exams":[32,15,7,22]},
              "Calum":{"matrix":23145,"email":"<EMAIL>","exams":[2,39,65,98]},
              "Dave":{"matrix":23562,"email":"<EMAIL>","exams":[97,78,92,88]},
              "Eve":{"matrix":55223,"email":"<EMAIL>","exams":[9,11,23,16]},
              }
# We can print out all the values of the keys.

for student in studentInfo:
    print(studentInfo[student])
# Now to print just the matrix numbers of the students.....

for student in studentInfo:
    print(studentInfo[student]["matrix"])
#Sometimes if the dictionary is deeply nested it is easier to use variables 
#rather than writing all the whole dictionary.

for student in studentInfo:
    s = studentInfo[student]
    print(s["matrix"])
# print out all the names and their email addresses<jupyter_output><empty_output><jupyter_text>Insert Fred's information into the dictionary.    exams = [54,45,55,44]    matrix = 22121    email = <EMAIL>    Does it matter the order the information is entered?<jupyter_code># find the average of every student's exam results and store the result in the dictionary.
*
# now save the students names in descending order of their average results 
# (use .sort() - ask a tutor if this is unclear).
# print a congratulations message to the top three students telling them their position in the class.

# Write a program to read in a sentence and print out how many times each letter occurs<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13060130218307162, 'fraction_numerical': 0.03446955189582535, 'mean_word_length': 4.593147751605995, 'pattern_counts': {'":': 25, '<': 15, '<?xml version=': 0, '>': 15, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '291255', 'license': 'CC0-1.0', 'n_tokens_mistral': 850, 'n_tokens_neox': 772, 'n_words': 297, 'path': 'dictionary_exercises.ipynb', 'repo_name': 'jeremysinger/glasgow-summer-school', 'size': '2651'}