0
0
Data Analysis Pythondata~10 mins

Word frequency analysis in Data Analysis Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to split the text into words.

Data Analysis Python
text = "Data science is fun and data is powerful."
words = text.[1]()
Drag options to blanks, or click blank then click option'
Areplace
Bjoin
Cstrip
Dsplit
Attempts:
3 left
💡 Hint
Common Mistakes
Using join() instead of split()
Using replace() which changes characters but does not split
Using strip() which only removes whitespace from ends
2fill in blank
medium

Complete the code to count how many times each word appears.

Data Analysis Python
from collections import [1]
counter = [1](words)
Drag options to blanks, or click blank then click option'
AOrderedDict
Bdefaultdict
CCounter
Dnamedtuple
Attempts:
3 left
💡 Hint
Common Mistakes
Using defaultdict which needs manual counting
Using OrderedDict which keeps order but does not count
Using namedtuple which is for fixed data structures
3fill in blank
hard

Fix the error in the code to get the most common word and its count.

Data Analysis Python
most_common_word, count = counter.[1](1)[0]
Drag options to blanks, or click blank then click option'
Amostcommon
Bmost_common
Ccommon_most
Dcommon
Attempts:
3 left
💡 Hint
Common Mistakes
Misspelling the method name
Using a method that does not exist
Trying to access attributes instead of calling a method
4fill in blank
hard

Fill both blanks to create a dictionary of words longer than 3 letters and their counts.

Data Analysis Python
filtered_counts = {word: counter[word] for word in counter if [1](word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen
B>
C<
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using count instead of len for word length
Using < instead of > for filtering
Not calling len as a function
5fill in blank
hard

Fill all three blanks to create a sorted list of words by frequency in descending order.

Data Analysis Python
sorted_words = sorted(counter.items(), key=lambda [1]: [2][[3]], reverse=True)
Drag options to blanks, or click blank then click option'
Ax
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 instead of 1 to sort by word instead of count
Using a different variable name inconsistently
Forgetting reverse=True for descending order