0
0
Pythonprogramming~10 mins

Python Interactive Mode vs Script Mode - Interactive Practice

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

Complete the code to print 'Hello, world!' in script mode.

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 put quotes around the text.
Using unquoted text which causes a NameError.
2fill in blank
medium

Complete the code to assign the number 5 to variable x in script mode.

Python
x = [1]
Drag options to blanks, or click blank then click option'
A"5"
B5
C'five'
Dfive
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around numbers, making them strings.
Using words instead of digits for numbers.
3fill in blank
hard

Fix the error in the interactive mode code to correctly print the sum of 2 and 3.

Python
print([1])
Drag options to blanks, or click blank then click option'
A2 + 3
B"2 + 3"
C2 plus 3
Dsum(2, 3)
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the expression inside quotes, which prints text instead of calculating.
Using incorrect function calls like sum(2, 3) which causes errors.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that includes only even numbers from 1 to 5.

Python
evens = {x: x[1]2 for x in range(1, 6) if x [2] 2 == 0}
Drag options to blanks, or click blank then click option'
A**
B%
C//
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of ** for squaring.
Using // instead of % for checking even numbers.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that converts keys to uppercase, keeps values, and filters 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'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using k instead of k.upper() for keys.
Using < instead of > for filtering values.