Chapter 8: More strings
True/False: Indexing of strings starts at 1, so the index of the first character is 1, the index of the second character is 2
False
True/False: The isupper method converts a string to all upper case characters
False
True/False: When you call a string's split method, the method divides the string into two substrings
False
What does the following snippet of code produce? name = 'Juliet' for ch in name: print(ch)
J u l I e t
What does the following code display? name = 'Joe' print(name.upper()) print(name.lower()) print(name)
JOE joe joe
What does the following code display? numbers = [ 1, 2, 3, 4, 5, 6, 7] print(numbers[4:6])
[5, 6]
What does the following code display? mystr = 'abc' * 3 print(mystr)
'abcabcabc'
What does the following code display? mystr = 'abcdefg' print(mystr[2:5])
'cde'
What does the following code display? mystr = 'yes' mystr += 'no' mystr += 'yes' print(mystr)
'yesnoyes'
True/False the repetition operator(*) works with strings as well as with lists
True
True/False: An 'IndexError' exception will occur if you try to use an index the is out of range for a particular string.
True
True/False: In python strings are immutable which means that once a string has be created it cannot be changed
True
True/False: Once a string is created, it cannot be changed
True
True/False: You can use the for loop to iterate over the individual characters in a string
True
This will happen if you try to use an index that is out of range for a string
an IndexError will occur
This method returns the lowest index in the string where a specified substring is found
find
One of the easiest ways to access the individual characters in a string is to use the____________
for loop
This operator determines whether one string is contained inside another string
in
This string method returns a copy of the string with all leading whiteface characters removed
lstrip
this string method returns a copy of the string with all the leading and trailing whitespace character removed
strip()
This string method returns true if a string contains only alphabetic characters and is at least one character in length
the isalpha() method
this string method returns true if a string contains only numeric digits and is at least one character in length
the isdigit() method