The names of modules inside a package
Predict the output · Challenge · §12.4, §12.5 Packages
There is a social package in the same folder. The first line of each of the two modules is a print() added for now to see which name the module was imported under. Predict the output of the code below.
Code
from social.text import tag
import social.counts
print(tag("nightview"))
print(social.counts.total([12, 30, 8]))File social/__init__.py
File social/counts.py
print("Loaded:", __name__)
def total(nums):
result = 0
for n in nums:
result += n
return resultFile social/text.py
print("Loaded:", __name__)
def tag(word):
return "#" + wordSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.