Question 1 (10 points)
undefined
Which of the following is the correct sequence of statements to output whether the first letter of the string ‘first’ is an f?
Question 2 (10 points)
undefined
What would be output by the following statements?
word = ‘welcome’
print(word[1:1])
Question 3 (10 points)
undefined
Which of the following would be output by this code?
word = ‘string’
print(word[6])
Question 4 (10 points)
undefined
Which of the following conditions checks whether the string ‘middle’ alphabetically follows ‘beginning’ and precedes ‘ending’?
Question 5 (10 points)
undefined
Which of the following is the correct program to count the number of occurrences of the letter r in the string ‘carrot’?
Question 6 (10 points)
undefined
Assuming the variable animal initially contains the string ‘mouse’, which of the following is the correct way to change animal to become ‘moose’?
Question 7 (10 points)
undefined
What would be output by the following statements?
fruit = ‘apple’
print(‘pl’ in fruit, ‘pa’ in fruit)
Question 8 (10 points)
undefined
Which of the following will be output by the following code?
word = ‘more’
index = 0
while index > len(word):
print(word[index])
index = index + 1
Question 9 (10 points)
undefined
Which of the following will be output by this program?
word = ‘ladder’
count = 0
for letter in word:
if letter == ‘d’:
count = count + 1
print(count)
Question 10 (10 points)
undefined
What would be output by the following statements?
word = ‘mississippi’
print(word.find(‘iss’), word.find(‘iss’, 2))


0 comments