Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to get a number from the user.
Python
number = [1]("Enter a number: ")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of input.
Forgetting to put parentheses after the function name.
✗ Incorrect
The input function reads text from the user.
2fill in blank
mediumComplete the code to show the message on the screen.
Python
[1]("Hello, friend!")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using input instead of print.
Forgetting to put parentheses after the function name.
✗ Incorrect
The print function shows text on the screen.
3fill in blank
hardFix the error in the code to get a number and print it.
Python
num = [1]("Type a number: ") print(num)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of input.
Trying to convert input without first reading it.
✗ Incorrect
Use input to get user input as text.
4fill in blank
hardFill both blanks to create a dictionary of word lengths for words longer than 3 letters.
Python
lengths = {word: [1] for word in words if len(word) [2] 3} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > in the condition.
Putting the word itself instead of its length in the dictionary.
✗ Incorrect
The dictionary stores each word with its length, but only if the word is longer than 3 letters.
5fill in blank
hardFill all three blanks to create a dictionary with uppercase keys and values greater than 0.
Python
result = {{ { [1] }: { [2] } for k, v in data.items() if v [3] 0 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > in the condition.
Using
k instead of k.upper() for keys.✗ Incorrect
This dictionary comprehension makes keys uppercase and includes only items with values greater than zero.