Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Python modules and imports code

Practice importing modules, selecting names, using aliases, and protecting top-level program code.

Beginner ~7 min read

Challenge 1

Import the math module.

python Your answer

print(math.sqrt(25))

Press Ctrl⌘Enter to check your answer

Challenge 2

Import sqrt directly from math.

python Your answer

print(sqrt(25))

Press Ctrl⌘Enter to check your answer

Challenge 3

Import math under the alias m.

python Your answer

print(m.sqrt(25))

Press Ctrl⌘Enter to check your answer

Challenge 4

Make main() run only when this file is executed directly.

python Your answer
def main():
    print("Running")

Press Ctrl⌘Enter to check your answer