Modules and imports
Every .py file is a module. A folder of modules is a package. import runs a module's top-level code once, caches it in sys.modules, and gives you a name for it.
import math
import json as js
from collections import Counter
print(math.pi)
print(js.dumps({"a": 1}))
print(Counter("aab"))Where Python looks
Python searches the folders in sys.path: the script's folder, then the standard library, then installed packages. A file named random.py next to your script hides the real random, so avoid names of standard modules.
The main guard
def main():
print("running")
if __name__ == "__main__":
main()A module's __name__ is "__main__" only when it runs as a script, so importing this file will not start main. Prefer import x over from x import *, so readers can see where every name came from.
Your task
Import from the standard library at the top of the file. Write circle_area(r) using math.pi. Write most_common_word(words) using from collections import Counter, returning the most frequent word (first seen wins a tie) or None for an empty list. Write to_json(data) returning JSON text with sorted keys.
The explanation opens here once every check passes.