Consider the following function:
def pr(a):
for c in a:
print(c, c, end=" ")
The result of calling this function with a particular string
a
is C C S S C C E E Y Y E E
. What was
a
?
What does the following program print?
def fl(tu):
= ""
r for v in tu:
+= str(v + v)
r return r
print(fl(("A", "C", 3)))
Suppose s = "Winter is cold."
Which of the following
evaluates to "r"
?
s[5]
s(5)
s[6]
s(6)
Suppose last_name = "Wehrwein"
. Which of the
following evaluates to "in"
? List all that apply.
last_name[7:8]
last_name[-2:8]
last_name[6:-1]
last_name[-3:]
last_name[6:]
Which of the following evaluates to the last character of a
string s
?
s[len(s) - 1]
s[len(s)]
s[len(s) + 1]
s[42]
Suppose last_name = "wehrwein"
. For which of the
following a
and b
will
last_name[a] == last_name[b]
evaluate to True
?
List all that apply.
a = 1
, b = 5
a = 1
, b = 7
a = 8
, b = -4
a = -2
, b = -6
What does the following code print?
= (4, 1, 2, 2, 2)
m = "Scott"
s for i in range(len(s)):
print(s[i] * m[i], end="")
Consider the following function:
def flop(value, number):
= ""
output for i in range(number, 0, -1):
= output + value[i-1]
output
for i in range(number, len(value)):
= output + value[i]
output return output
Suppose a
contains an integer. Which of the following
are possible return values of the following call:
"no time", a) flop(
List all that apply:
mit one
nomite
t onime
on time
emit on
timeno time