A weekly view report
Predict the output · Medium · §8.2, §8.5 Inside and outside a function
This is made-up data that assumes the number of views is the same every day. Predict the four lines of output without running the code.
Code
total = 0
def weekly(views):
total = views * 7
print("Weekly:", total)
return total
def report(n):
print("Total:", n)
a = weekly(100) + weekly(50)
b = report(a)
print(a, b, total)Solve 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.