Filters
Question type

Study Flashcards

The index -1 identifies the last character in a string.

Correct Answer

verifed

verified

What will be assigned to the string variable pattern after the execution of the following code? i = 3 Pattern = 'z' * (5*i)


A) 'zzzzzzzzzzzzzzz'
B) 'zzzzz'
C) Error: '*' operator used incorrectly
D) The right side of the '*' must be an integer.

Correct Answer

verifed

verified

An expression of the form string[i] = 'i' is a valid expression.

Correct Answer

verifed

verified

What will be assigned to s_string after the execution of the following code? special = '1357 Country Ln.' S_string = special[-3: ]


A) '531'
B) 'Ln.'
C) ' Ln.'
D) '7531'

Correct Answer

verifed

verified

The third number in string slicing brackets represents the _______________ value.

Correct Answer

verifed

verified

If a whole paragraph is included in a single string, the split() method can be used to obtain a list of the sentences included in the paragraph.

Correct Answer

verifed

verified

True

Which method would you use to determine whether a substring is present in a string?


A) endswith(substring)
B) find(substring)
C) replace(string, substring)
D) startswith(substring)

Correct Answer

verifed

verified

Invalid indexes do not cause slicing expressions to raise an exception.

Correct Answer

verifed

verified

Indexing works with both strings and lists.

Correct Answer

verifed

verified

What are the valid indexes for the string 'New York'?


A) 0 through 7
B) 0 through 8
C) -1 through -8
D) -1 through 6

Correct Answer

verifed

verified

What will be assigned to s_string after the execution of the following code? special = '1357 Country Ln.' S_string = special[4: ]


A) '1357'
B) 'Country Ln.'
C) ' Country Ln.'
D) Invalid code

Correct Answer

verifed

verified

The strip() method returns a copy of the string with all leading whitespace characters removed, but does not remove trailing whitespace characters.

Correct Answer

verifed

verified

What will be assigned to the string variable even after the execution of the following code? special = '0123456789' Even = special[0:10:2]


A) '13579'
B) '2468'
C) '02468'
D) Invalid code

Correct Answer

verifed

verified

The _______________ method returns a copy of the string with all alphabetic letters converted to lower case.

Correct Answer

verifed

verified

lower()

What is the first negative index in a string?


A) 0
B) -1
C) -0
D) Size of the string minus one

Correct Answer

verifed

verified

The _______________ operator can be used to determine whether one string is contained in another string.

Correct Answer

verifed

verified

in

When accessing each character in a string, such as for copying purposes, you would typically use a while loop.

Correct Answer

verifed

verified

The _______________ method returns the list of the words in the string.

Correct Answer

verifed

verified

What will be assigned to s_string after the execution of the following code? special = '1357 Country Ln.' S_string = special[ :4]


A) '7'
B) '1357'
C) '1357 '
D) Invalid code

Correct Answer

verifed

verified

In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead.

Correct Answer

verifed

verified

Showing 1 - 20 of 35

Related Exams

Show Answer