D. Do the online reading: Overloading the plus operator, doing the next set of questions while you do so. 1. 11 + 22 evaluates to: (HINT: enter error if it generates an error) ANS. 33 2. '11' + '22' evaluates to: (HINT: enter error if it generates an error) ANS. '1122' ANS. 1122 ANS. "1122" 3. '11' + str(3 + 3) + '22' evaluates to: (HINT: enter error if it generates an error) ANS. '11622' ANS. "11622" ANS. 11622 4. '11' + 33 evaluates to: (HINT: enter error if it generates an error) ANS. error ANS. ERROR 5. What does the following code snippet print:
 x = 1 
y = 2
z = 3
print(x, y, z)
a. 1, 2, 3 b. 1 2 3~ c. 6 d. 123 6. What does the following code snippet print:
 x = 1 
y = 2
z = 3
print(str(x) + str(y) + str(z))
a. 1, 2, 3 b. 1 2 3 c. 6 d. 123~ 7. What does the following code snippet print:
 x = 1 
y = 2
z = 3
print(x + y + z)
a. 1, 2, 3 b. 1 2 3 c. 6~ d. 123 8. What does the following code snippet print:
 x = 1 
y = 2
z = 3
print(str(x + y) + str(z))
ANS. 33 9. Implement a function named print_equation that given two numbers x and y prints an equation for the sum of them. For example, if x is 65 and y is 11, the function would print 65+11=76. M. Line 1 -> def print_equation(x, y): M. Line 2 ->     print(str(x) + "+" + str(y) + "=" + str(x+y)) M. ->     print(x, y, x+y) M. ->     print(x+++y+ = +x+y) M. ->     print("65+11=76") D. Do the online reading: Accumulating Sequences, doing the next set of questions while you do so. D. On a piece of paper (NOT here in Moodle), implement the following function, per its doc-string. You do NOT have to be completely correct, just try to get the main idea correct, with guidance from the reading. After you have made a reasonable try, turn to the next page in this Moodle quiz for a solution.
def make_simple_list(m, n):
"""
Returns the list [m, m+1, m+2, ... n],
where m and n are the given arguments.
For example, if m is 5 and n is 13,
then this function returns:
[5, 6, 7, 8, 9, 10, 11, 12, 13]
"""
D. Here is a solution to the previous problem. Compare your solution to it. Bring any questions about this problem to class.
def make_simple_list(m, n):
"""
Returns the list [m, m+1, m+2, ... n],
where m and n are the given arguments.
For example, if m is 5 and n is 13,
then this function returns:
[5, 6, 7, 8, 9, 10, 11, 12, 13]
"""
seq = []
for k in range(m, n + 1):
seq = seq + [k]
return seq
1. Consider the following code. What should the missing statement be (that is, the statement marked ???).
def make_list(n):
"""
Returns the list [1, 2, 3, ... n],
where n is the given argument.
For example, if n is 5,
then this function returns:
[1, 2, 3, 4, 5]
"""
seq = []
for k in range(n):
???
return seq
a. seq = seq[k+1] b. seq = seq + k + 1 c. seq = seq[k] + [k] d. seq[k] = seq[k] + [k] e. seq = seq + [k + 1]~ e. seq = seq + [k] D. Watch the video: Sequences, doing the next set of questions while you do so. D. For the next set of questions, consider the following three function definitions:
def foo1(seq):
total = 0
for k in range(len(seq) // 2):
total = total + seq[1 + (2 * k)]
return total


def foo2(seq):
total = 0
for k in range(1, len(seq), 2):
total = total + seq[k]
return total


def foo3(seq):
total = 0
m = 1
for _ in range(len(seq) // 2):
total = total + seq[m]
m = m + 2
return total
1. To what number does foo1([3]) evaluate? a. 0~ b. 1 c. 2 d. 3 e. 4 f. 5 g. 6 h. 7 i. 8 j. 9 k. 10 l. 11 m. 12 n. 13 o. 14 p. 15 q. 16 r. 17 r. 18 r. 19 r. 20 r. 24 r. 33 r. 38 1. To what number does foo1([3, 6]) evaluate? a. 0 b. 1 c. 2 d. 3 e. 4 f. 5 g. 6~ h. 7 i. 8 j. 9 k. 10 l. 11 m. 12 n. 13 o. 14 p. 15 q. 16 r. 17 r. 18 r. 19 r. 20 r. 24 r. 33 r. 38 1. To what number does foo1([3, 6, 1, 4, 9, 5]) evaluate? a. 0 b. 1 c. 2 d. 3 e. 4 f. 5 g. 6 h. 7 i. 8 j. 9 k. 10 l. 11 m. 12 n. 13 o. 14 p. 15~ q. 16 r. 17 r. 18 r. 19 r. 20 r. 24 r. 33 r. 38 1. To what number does foo2([3]) evaluate? a. 0~ b. 1 c. 2 d. 3 e. 4 f. 5 g. 6 h. 7 i. 8 j. 9 k. 10 l. 11 m. 12 n. 13 o. 14 p. 15 q. 16 r. 17 r. 18 r. 19 r. 20 r. 24 r. 33 r. 38 1. To what number does foo2([3, 6]) evaluate? a. 0 b. 1 c. 2 d. 3 e. 4 f. 5 g. 6~ h. 7 i. 8 j. 9 k. 10 l. 11 m. 12 n. 13 o. 14 p. 15 q. 16 r. 17 r. 18 r. 19 r. 20 r. 24 r. 33 r. 38 1. To what number does foo2([3, 6, 1, 4, 9, 5]) evaluate? a. 0 b. 1 c. 2 d. 3 e. 4 f. 5 g. 6 h. 7 i. 8 j. 9 k. 10 l. 11 m. 12 n. 13 o. 14 p. 15~ q. 16 r. 17 r. 18 r. 19 r. 20 r. 24 r. 33 r. 38 1. To what number does foo3([3]) evaluate? a. 0~ b. 1 c. 2 d. 3 e. 4 f. 5 g. 6 h. 7 i. 8 j. 9 k. 10 l. 11 m. 12 n. 13 o. 14 p. 15 q. 16 r. 17 r. 18 r. 19 r. 20 r. 24 r. 33 r. 38 1. To what number does foo3([3, 6]) evaluate? a. 0 b. 1 c. 2 d. 3 e. 4 f. 5 g. 6~ h. 7 i. 8 j. 9 k. 10 l. 11 m. 12 n. 13 o. 14 p. 15 q. 16 r. 17 r. 18 r. 19 r. 20 r. 24 r. 33 r. 38 1. To what number does foo3([3, 6, 1, 4, 9, 5]) evaluate? a. 0 b. 1 c. 2 d. 3 e. 4 f. 5 g. 6 h. 7 i. 8 j. 9 k. 10 l. 11 m. 12 n. 13 o. 14 p. 15~ q. 16 r. 17 r. 18 r. 19 r. 20 r. 24 r. 33 r. 38 D. For the next set of questions, consider the following two attempts at a function that returns the first negative item in the sequence of numbers, or None if the sequence contains no negative numbers. One is correct and the other is wrong.
def find1(numbers):
for k in range(len(numbers)):
if numbers[k] < 0:
return numbers[k]
else:
return None


def find2(numbers):
for k in range(len(numbers)):
if numbers[k] < 0:
return numbers[k]
return None


1. To what number does find1([-3, 6, 1, 4, 9, 5]) evaluate? ANS. -3 1. To what number does find2([-3, 6, 1, 4, 9, 5]) evaluate? ANS. -3 1. To what number does find1([3, 6, 1, 4, 9, 5]) evaluate? ANS. None 1. To what number does find2([3, 6, 1, 4, 9, 5]) evaluate? ANS. None 1. To what number does find1([3, -6, 1, 4, 9, 5]) evaluate? ANS. None 1. To what number does find2([3, -6, 1, 4, 9, 5]) evaluate? ANS. -6 1. Which attempt is correct? a. find1 b. find2~