0
0
Data Analysis Pythondata~10 mins

String cleaning (strip, lower, replace) 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 remove spaces from the start and end of the string.

Data Analysis Python
cleaned = raw_string.[1]()
Drag options to blanks, or click blank then click option'
Astrip
Blower
Creplace
Dsplit
Attempts:
3 left
💡 Hint
Common Mistakes
Using lower() instead of strip()
Using replace() without specifying what to replace
2fill in blank
medium

Complete the code to convert the string to all lowercase letters.

Data Analysis Python
cleaned = raw_string.[1]()
Drag options to blanks, or click blank then click option'
Acapitalize
Blower
Creplace
Dstrip
Attempts:
3 left
💡 Hint
Common Mistakes
Using strip() instead of lower()
Using capitalize() which only changes the first letter
3fill in blank
hard

Fix the error in the code to replace all commas with semicolons.

Data Analysis Python
cleaned = raw_string.[1](',', ';')
Drag options to blanks, or click blank then click option'
Areplace
Bstrip
Clower
Dsplit
Attempts:
3 left
💡 Hint
Common Mistakes
Using strip() which does not replace characters
Using lower() which changes case, not characters
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.

Data Analysis Python
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of len(word) for values
Using < instead of > in the condition
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase words as keys, original words as values, only for words containing 'a'.

Data Analysis Python
result = [1]: [2] for word in words if '[3]' in word}
Drag options to blanks, or click blank then click option'
Aword.upper()
Bword
Ca
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.lower() instead of word.upper() for keys
Checking for 'A' instead of 'a' in the condition