Filters
Question type

Study Flashcards

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

E) C) and D)
F) A) and B)

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.

A) True
B) False

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

E) A) and C)
F) A) and D)

Correct Answer

verifed

verified

Indexing of a string starts at 1, so the index of the first character is 1, the index of the second character is 2, and so forth.

A) True
B) False

Correct Answer

verifed

verified

False

Which method would you use to determine whether a substring is the suffix of a string?


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

E) None of the above
F) C) and D)

Correct Answer

verifed

verified

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

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

E) B) and D)
F) A) and D)

Correct Answer

verifed

verified

C

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

A) True
B) False

Correct Answer

verifed

verified

Which list will be referenced by the variable list_strip after the execution of the following code? List_string = '03/07/2008' List_strip = list_string.split('/')


A) ['3', '7', '2008']
B) ['03', '07', '2008']
C) ['3', '/', '7', '/', '2008']
D) ['03', '/', '07', '/', '2008']

E) C) and D)
F) None of the above

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.

A) True
B) False

Correct Answer

verifed

verified

Indexing works with both strings and lists.

A) True
B) False

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

When the operand on the left side of the * symbol is a string and the operand on the right side is an integer, it becomes the _______________ operator.

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

E) None of the above
F) All of the above

Correct Answer

verifed

verified

If the + operator is used on strings, it produces a string that is the combination of the two strings used as its operands.

A) True
B) False

Correct Answer

verifed

verified

Each character in a string has a(n) _______________ which specifies its position in the string.

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

Which of the following string methods can be used to determine if a string contains only '\n' characters?


A) ischar()
B) isalpha()
C) istab()
D) isspace()

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

D

Strings are _______________, which means that once a string is created, it cannot be changed.

Correct Answer

verifed

verified

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)

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

Showing 1 - 20 of 35

Related Exams

Show Answer