Exam 8: More About Strings

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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

Free
(True/False)
4.7/5
(80)
Correct Answer:
Verified

False

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

Free
(Short Answer)
4.9/5
(81)
Correct Answer:
Verified

lower()

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.

Free
(True/False)
4.9/5
(78)
Correct Answer:
Verified

False

The __________ method returns True if the string contains only numeric digits.

(Short Answer)
4.8/5
(69)

What will be displayed after the following code executes? Mystr = 'yes' Yourstr = 'no' Mystr += yourstr * 2 Print(mystr)

(Multiple Choice)
5.0/5
(69)

What will be the value of the variable string after the following code executes? String = 'abcd' String.upper()

(Multiple Choice)
4.8/5
(75)

A(n)__________ exception will occur if you try to use an index that is out of range for a particular string.

(Short Answer)
4.8/5
(84)

The isalpha()method returns __________ if the string contains only alphabetic characters and is at least one character in length.

(True/False)
5.0/5
(89)

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

(Short Answer)
4.9/5
(85)

What will display after the following code executes? Password = 'ILOVEPYTHON' If password.isalpha(): Print('Invalid,must contain one number.') Elif password.isdigit(): Print('Invalid,must have one non-numeric character.') Elif password.isupper(): Print('Invalid,cannot be all uppercase characters.') Else: Print('Your password is secure!')

(Multiple Choice)
4.7/5
(72)

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

(Multiple Choice)
4.8/5
(70)

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

(Multiple Choice)
4.8/5
(75)

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

(Multiple Choice)
4.8/5
(80)

Indexing works with both strings and lists.

(True/False)
4.9/5
(88)

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

(Short Answer)
4.7/5
(69)

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

(Multiple Choice)
4.9/5
(71)

What will be the value of the variable string after the following code executes? String = 'Hello' String += ' world!'

(Multiple Choice)
4.9/5
(82)

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

(True/False)
4.8/5
(73)

What is the first negative index in a string?

(Multiple Choice)
4.9/5
(81)

The __________ method returns the list of the words in a string.

(Short Answer)
4.9/5
(89)
Showing 1 - 20 of 37
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)