0
0
Pythonprogramming~10 mins

Creating custom modules in Python - Interactive Practice

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

Complete the code to import the custom module named mymodule.

Python
import [1]
Drag options to blanks, or click blank then click option'
Amymodule
Bsys
Cos
Drandom
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to import a module that is not in the same folder or Python path.
Using the wrong module name.
2fill in blank
medium

Complete the code to call the function greet from the mymodule.

Python
mymodule.[1]()
Drag options to blanks, or click blank then click option'
Ahello
Bsay_hello
Cgreet
Dwelcome
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a function name that does not exist in the module.
Forgetting the parentheses to call the function.
3fill in blank
hard

Fix the error in the import statement to correctly import the greet function from mymodule.

Python
from mymodule [1] greet
Drag options to blanks, or click blank then click option'
Aimport
Bimporting
Cimports
Dinclude
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect keywords like importing or include.
Misspelling import.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length from the list words, but only for words longer than 3 characters.

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

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths, but only for words with length greater than 4.

Python
{ [1]: [2] for word in words if len(word) [3] 4 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.lower() instead of uppercase.
Using wrong comparison operators like < or ==.