Chapter 8

¡Supera tus tareas y exámenes ahora con Quizwiz!

This string method returns the lowest index in the string where a specified substring is found

find

This operator determines whether one string is contained inside another string

in

This function returns the length of a string

len

What does the following code display? name = 'shmoe' print(name.lower()) print(name.upper()) print(name)

shmoe SHMOE shmoe

This string method returns a copy of the string with all leading and trailing whitespace characters 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

T/F: You can use the for loop to iterate over the individual characters in a string

true

What does the following code display? word= ' yes' word+= 'no' word += 'yes' print(word)

yesnoyes

This is the first string in an index

0

T/F: The isupper method converts a string to all uppercase characters

False

T/F: When you call a string's split method, the method divides the string into two substrings

False

This is the last index in a string

The size of the string minus one

T/F: Once a string is created, it cannot be changed

True

T/F: The repetition operator (*) works with strings as well as with lists

True

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? astring = 'abc' * 3 print (astring)

abcabcabc

This will happen if you try to use an index that is out of range for a string

an IndexError exception will occur

What will the following code display? astring = 'abcdef' print(astring[2:5])

cde

This string method returns a copy of the string with all leading whitespace characters removed

lstrip


Conjuntos de estudio relacionados

Domain 4.0 Identity and Access Management

View Set

Final Exam - Chapters 10 - 17 INTERNATIONAL BUSINESS

View Set

Standard Position, Coterminal and Reference Angles

View Set

3090 Research Methods Exam 1 study

View Set

6 trig function ratios for the angles 0, 30, 60, 90, 180, 270, 360

View Set