Complete the code to read a Unicode text file correctly.
with open('text.txt', encoding=[1]) as f: content = f.read()
UTF-8 is the most common encoding for Unicode text files and supports all Unicode characters.
Complete the code to normalize Unicode text to NFC form.
import unicodedata normalized_text = unicodedata.normalize([1], text)
NFC (Normalization Form C) composes characters to their composed form, which is standard for text processing.
Fix the error in decoding bytes to a Unicode string.
byte_data = b'caf\xc3\xa9' text = byte_data.[1]('utf-8')
Bytes must be decoded to get a Unicode string. The decode method converts bytes to str.
Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.
word_lengths = {word: [1] for word in words if len(word) [2] 3}We want the length of each word (len(word)) and only words longer than 3 characters (len(word) > 3).
Fill all three blanks to filter and transform a dictionary with Unicode keys and values.
filtered = {{ [1]: [2] for k, v in data.items() if v [3] 0 }}We transform keys to uppercase (k.upper()), keep values as is (v), and filter values greater than zero (v > 0).