Exercises
Comments
3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.
Exercise 1Passed
Switch off the middle line with a comment so only the first and third print.
Python
print("first")
print("second")
print("third")A # at the start of a line makes Python skip it.
print("first")
# print("second")
print("third")Exercise 2Passed
Give the function a docstring saying what it returns, then print that docstring.
Python
def area(width, height):
return width * height
print(area.__doc__)A string on the first line of the function body becomes its docstring.
def area(width, height):
"""Return the area of a rectangle."""
return width * height
print(area.__doc__)Exercise 3Passed
Replace the useless comment with one that explains why the limit is 50.
Python
# set batch size to 50
batch_size = 50
print(batch_size)The code already says what. Say why: the API rejects more than 50 per call.
# The API rejects more than 50 ids per call, so send them in batches
batch_size = 50
print(batch_size)