Complete the code to load a text document from a file.
with open('document.txt', '[1]') as file: content = file.read()
The mode 'r' opens the file for reading, which is needed to load the document content.
Complete the code to split the loaded document content into sentences.
sentences = content.[1]('.')
The split method breaks the text into parts using the given separator, here a period.
Fix the error in the code to parse JSON content from a document string.
import json parsed_data = json.[1](content)
The loads function parses a JSON string into a Python object.
Fill both blanks to create a dictionary of word counts from the document.
word_counts = {word: content.[1](word) for word in content.[2]()}The split method breaks the content into words, and count counts how many times each word appears.
Fill all three blanks to filter sentences containing a keyword and count them.
keyword = 'AI' filtered = [sentence for sentence in content.[1]('.') if [2] in sentence.[3]()] count = len(filtered)
We split the content into sentences, check if the keyword is in each sentence after converting it to lowercase, then count the filtered sentences.