Which of the following belongs in a function’s docstring? List all that apply.
Consider the following function:
def print_squares(n):
""" docstring missing! help! """
i = 0
while i < n:
i += 1
print(i, i**2)
return i**2The function prints the square of each number from 1 through n
The function uses a while loop
The function returns the square of n
The function returns the square of i
The function uses a counter variable called i
Consider the following program, noticing that several points in the code are marked with comments (e.g., M1). Important: the markers refer to the lines they’re on, not the lines following them.
M1 through M5) is v2 in scope? List all that apply.M1 through M5) is v3 in scope? List all that apply.Consider the following program:
def print_rectangle_area(width, height):
""" Print the area of a width-by-height
rectangle. Pre: width and height are numbers. """
area = width * height
print(area)
w = 4
h = 3
a = w * h
print_rectangle_area(w, h)Which of the following could replace the last line of the program and leave its behavior unchanged? List all that apply.
print(h*w)
print(width * height)
print(w * h)
print_rectangle_area(h, w)
What does the following program print?
What does the following program print?
There are no new Problems for today - continue the Peer Review process from last class if you need more time to finish, then work on the Problems from L10.