0
0
Pythonprogramming~10 mins

Why Python is easy to learn - Test Your Understanding

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

Complete the code to print a friendly greeting in Python.

Python
print([1])
Drag options to blanks, or click blank then click option'
AHello, friend!
Bprint("Hello, friend!")
C"Hello, friend!"
D'Hello friend'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the text
Trying to print without quotes
2fill in blank
medium

Complete the code to create a list of three fruits.

Python
fruits = [[1]]
Drag options to blanks, or click blank then click option'
Aapple, banana, cherry
B"apple", "banana", "cherry"
C'apple', 'banana', 'cherry'
D"apple" "banana" "cherry"
Attempts:
3 left
💡 Hint
Common Mistakes
Missing commas between items
Not using quotes around strings
3fill in blank
hard

Fix the error in the code to check if a number is even.

Python
if number [1] 2 == 0:
    print("Even number")
Drag options to blanks, or click blank then click option'
A+
B//
C*
D%
Attempts:
3 left
💡 Hint
Common Mistakes
Using // which does floor division
Using * or + which are arithmetic but not remainder
4fill in blank
hard

Fill both blanks to create a dictionary of squares for numbers 1 to 5.

Python
squares = {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 power
Using == instead of != for odd check
5fill in blank
hard

Fill all three blanks to filter and transform a dictionary of words and their lengths.

Python
result = [1]: [2] for word in words if len(word) [3] 3}
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.upper() changes keys unnecessarily
Using < instead of > in condition