Question: word = 'more' index = 0 while index < len(word): print(word[index]) index = index + 1 Question 1 options: It would generate an IndexError m

word = 'more' index = 0 while index < len(word): print(word[index]) index = index + 1

Question 1 options:

It would generate an IndexError

m o r e

m o r

o r e

Which of the following is the correct program to count the number of occurrences of the letter l in the string 'yellow'?

Question 2 options:

color = 'yellow' count = 0 for letter in color: if letter == 'l': count = count + 1 print(count)

color = 'yellow' count = 0 for letter l in color: if l == 'l': count = count + 1 print(count)

color = 'yellow' count = 0 for 'l' in color: count = count + 1 print(count)

color = 'yellow' count = 0 for letter in color: if color[i] == 'l': count = count + 1 print(count)

What would be output by the following statements?

vegetable = 'carrot' print(vegetable > 'spinach', vegetable > 'broccoli')

Question 3 options:

False False

True False

False True

True True

What would be output by the following statements?

word = 'welcome' print(word[1:])

Question 4 options:

e

welcome

w

elcome

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 5 options:

4

5

2

6

Assuming the variable animal initially contains the string 'rat', which of the following is the correct way to change animal to become 'cat'?

Question 6 options:

animal = 'c' + animal[0:]

animal[1] = 'c'

animal[0] = 'c'

animal = 'c' + animal[1:]

Which of the following statements outputs whether the first non-blank character of the string contained in the variable named word is a b?

Question 7 options:

print(word.strip().startswith('b'))

print(word.trim().startswith('b'))

print(word.firstnonblank('b'))

print(word('b').isfirstnonblank())

Which of the following conditions checks whether the variables alpha, beta and gamma, which contain strings, are in alphabetic order?

Question 8 options:

alpha < beta or beta < gamma

alpha < beta < gamma

not(alpha < beta or beta < gamma)

alpha in beta and beta in gamma

Which of the following would be output by this code?

word = 'string' print(word[0])

Question 9 options:

s

t

It would generate an IndexError

g

What would be output by the following statements?

word = 'mississippi' print(word.find('iss'), word.find('iss', 2))

Question 10 options:

2 2

1 1

2 5

1 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!