0
0
Prompt Engineering / GenAIml~10 mins

Text splitters in Prompt Engineering / GenAI - 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 using spaces.

Prompt Engineering / GenAI
words = text[1](" ")
Drag options to blanks, or click blank then click option'
A.replace
B.split
C.join
D.strip
Attempts:
3 left
💡 Hint
Common Mistakes
Using join instead of split
Forgetting to specify the separator
2fill in blank
medium

Complete the code to split the text into sentences using the period character.

Prompt Engineering / GenAI
sentences = text[1](".")
Drag options to blanks, or click blank then click option'
A.join
B.replace
C.strip
D.split
Attempts:
3 left
💡 Hint
Common Mistakes
Using join instead of split
Using replace which changes text but does not split
3fill in blank
hard

Fix the error in the code to split text by commas.

Prompt Engineering / GenAI
parts = text[1](",")
Drag options to blanks, or click blank then click option'
A.split
B.join
C.replace
D.strip
Attempts:
3 left
💡 Hint
Common Mistakes
Using join which combines text
Using replace which changes text but does not split
4fill in blank
hard

Fill both blanks to create a dictionary with words as keys and their lengths as values, only for words longer than 3 letters.

Prompt Engineering / GenAI
lengths = {word[1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
A: len(word)
B>
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >
Forgetting the colon between key and value
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase words as keys, their counts as values, only for words appearing more than once.

Prompt Engineering / GenAI
result = [1]: [2] for [3], count in word_counts.items() if count > 1}
Drag options to blanks, or click blank then click option'
Aword.upper()
Bcount
Cword
Dcount.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using count.upper() which is invalid
Swapping key and value positions