0
0
Pythonprogramming~10 mins

How Python executes code - Interactive Practice

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

Complete the code to print a greeting message.

Python
print([1])
Drag options to blanks, or click blank then click option'
A"Hello, world!"
BHello, world!
Cprint
Dgreeting
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the text.
Trying to print a variable that is not defined.
2fill in blank
medium

Complete the code to assign the number 5 to variable x.

Python
x = [1]
Drag options to blanks, or click blank then click option'
Ax
B"5"
Cfive
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around numbers.
Using variable names instead of values.
3fill in blank
hard

Fix the error in the code to correctly add two numbers.

Python
result = 3 [1] 4
Drag options to blanks, or click blank then click option'
A-
B+
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using minus or other operators instead of plus.
Forgetting the operator.
4fill in blank
hard

Fill both blanks to create a dictionary with 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'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of len(word) for length.
Using < instead of > for filtering.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values greater than zero.

Python
result = {{ [1]: [2] for k, v in data.items() if v [3] 0 }}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using k instead of k.upper() for keys.
Using < or other operators instead of >.
Using k instead of v for values.