Consider the following function:
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?
Suppose s = "Winter is coming."
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?
Consider the following function:
def flop(value, number):
output = ""
for i in range(number, 0, -1):
output = output + value[i-1]
for i in range(number, len(value)):
output = output + value[i]
return output
Suppose a
contains an integer. Which of the following are possible return values of the following call:
List all that apply:
mit one
nomite
t onime
on time
emit on
timeno time
Implement the following function:
Implement the following function, which differs only in that it returns the string without vowels:
Implement the following function:
Implement the following function:
Write a function that takes a string and prints all prefixes of the string, including the string itself.
Implement the following function:
Write an add_banner
function that takes a string argument and prints that string, surrounded by a rectangle of #
symbols. If the string is longer than 80 characters, break the string into multiple lines. You can assume the string does not contain any newlines. An example might look something like the following:
>>> print_banner("Modify your print_banner to implement text wrapping so that a string longer than 80 characters will be broken into multiple lines.")
##################################################################################
#Modify your print_banner to implement text wrapping so that a string longer than#
#80 characters will be broken into multiple lines. #
##################################################################################
>>>