0
0
Pythonprogramming~10 mins

String values and text handling in 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 print the string 'Hello, World!'.

Python
print([1])
Drag options to blanks, or click blank then click option'
A'Hello, World!'
BHello, World!
C"Hello World"
DHello World
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use quotes around the text.
Using quotes inconsistently or missing them.
2fill in blank
medium

Complete the code to get the length of the string stored in variable text.

Python
length = [1](text)
Drag options to blanks, or click blank then click option'
Acount
Blen
Csize
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent functions like count or size for length.
Trying to access length as an attribute instead of a function.
3fill in blank
hard

Fix the error in the code to convert the string to uppercase.

Python
result = text.[1]()
Drag options to blanks, or click blank then click option'
AupperCase
Buppercase
Cupper
DtoUpperCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using JavaScript style method names like toUpperCase.
Capitalizing method names incorrectly.
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 characters.

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 the word itself as the value instead of its length.
Using the wrong comparison operator in the condition.
5fill in blank
hard

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

Python
result = {{ [1]: [2] for word in words if word.[3]('a')}
Drag options to blanks, or click blank then click option'
Aword.upper()
Bword
Cstartswith
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lower() instead of upper() for keys.
Using the wrong method name for checking the start of a string.