Complete the code to split the text into words.
text = "Data science is fun and data is powerful." words = text.[1]()
The split() method breaks the text into a list of words separated by spaces.
Complete the code to count how many times each word appears.
from collections import [1] counter = [1](words)
Counter from collections counts the frequency of each item in a list.
Fix the error in the code to get the most common word and its count.
most_common_word, count = counter.[1](1)[0]
The correct method name is most_common() which returns a list of tuples with word and count.
Fill both blanks to create a dictionary of words longer than 3 letters and their counts.
filtered_counts = {word: counter[word] for word in counter if [1](word) [2] 3}We use len(word) to get word length and filter words with length greater than 3 using >.
Fill all three blanks to create a sorted list of words by frequency in descending order.
sorted_words = sorted(counter.items(), key=lambda [1]: [2][[3]], reverse=True)
The lambda function takes each item x and sorts by the second element x[1] which is the count. reverse=True sorts descending.