May 2019
Beginner
528 pages
29h 51m
English
6.1 (Discussion: Dictionary Methods) Briefly explain the operation of each of the following dictionary methods:
add
keys
values
items
6.2 (What’s Wrong with This Code?) The following code should display the unique words in the string text and the number of occurrences of each word.
from collections import Countertext = ('to be or not to be that is the question')counter = Counter(text.split())for word, count in sorted(counter):print(f'{word:<12}{count}')
6.3 (What Does This Code Do?) The dictionary temperatures contains three Fahrenheit temperature samples for each of four days. What does the for statement do?
temperatures = {'Monday': [66, 70, 74],'Tuesday': [50, 56, 64],'Wednesday': [75, 80, 83],'Thursday': [67, 74 ...
Read now
Unlock full access