Starting Out with Python, 3e Ch 8

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Returns a copy of the string with all alphabetic letters converted to lowercase. Any character that is already lowercase, or is not an alphabetic letter, is unchanged.

lower( )

This string method returns a copy of the string with all leading whitespace characters removed. a. lstrip b. rstrip c. remove d. strip_leading

lstrip

Returns a copy of the string with all leading whitespace characters removed. Leading whitespace characters are spaces, newlines (\n), and tabs (\t) that appear at the beginning of the string.

lstrip( )

The char argument is a string containing a character. Returns a copy of the string with all instances of char that appear at the beginning of the string removed.

lstrip(char)

The old and new arguments are both strings. The method returns a copy of the string with all instances of old replaced by new.

replace(old, new)

Returns a copy of the string with all trailing whitespace characters removed. Trailing whitespace characters are spaces, newlines (\n), and tabs (\t) that appear at the end of the string.

rstrip( )

The char argument is a string containing a character. The method returns a copy of the string with all instances of char that appear at the end of the string removed.

rstrip(char)

The substring argument is a string. The method returns true if the string starts with substring.

startswith(substring)

This string method returns a copy of the string with all leading and trailing whitespace characters removed. a. clean b. strip c. remove_whitespace d. rstrip

strip

Returns a copy of the string with all leading and trailing whitespace characters removed.

strip( )

Returns a copy of the string with all instances of char that appear at the beginning and the end of the string removed.

strip(char)

a slice from a string, you get a span of characters from within the string. String slices are also called

substrings

This string method returns true if a string contains only alphabetic characters and is at least one character in length. a. the isalpha method b. the alpha method c. the alphabetic method d. the isletters method

the isalpha method

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

True

How do you find the length of a string?

Use the len( ) function

appending one string to the end of another string

concatenation

This function returns the length of a string. a. length b. size c. len d. lengthof

len

This string method returns the lowest index in the string where a specified substring is found. a. first index of b. locate c. find d. index of

find

The substring argument is a string. The method returns the lowest index in the string where substring is found. If substring is not found, the method returns -1.

find(substring)

means that once they are created, they cannot be changed

immutable

This operator determines whether one string is contained inside another string. a. contains b. is in c. == d. in

in

Returns true if the string contains only alphabetic letters or digits and is at least one character in length. Returns false otherwise.

isalnum( )

Returns true if the string contains only alphabetic letters and is at least one character in length. Returns false otherwise.

isalpha( )

Returns true if the string contains only numeric digits and is at least one character in length. Returns false otherwise.

isdigit( )

Returns true if all of the alphabetic letters in the string are lowercase, and the string contains at least one alphabetic letter. Returns false otherwise.

islower( )

Returns true if the string contains only whitespace characters and is at least one character in length. Returns false otherwise. (Whitespace characters are spaces, newlines (\n), and tabs (\t).

isspace( )

Returns true if all of the alphabetic letters in the string are uppercase, and the string contains at least one alphabetic letter. Returns false otherwise.

isupper( )

What happens if you try to use an invalid index to access a character in a string?

An IndexError Exception occurs

The isupper method converts a string to all uppercase characters. T or F

False

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

False

This is the first index in a string. a. - 1 b. 1 c. 0 d. The size of the string minus one

0

What is the index of the first character in a string?

0

If a string has 10 characters, what is the index of the last character?

9

This will happen if you try to use an index that is out of range for a string. a. A ValueError exception will occur. b. An IndexError exception will occur. c. The string will be erased and the program will continue to run. d. Nothing-the invalid index will be ignored.

An IndexError exception will occur.

This is the last index in a string. a. 1 b. 99 c. 0 d. The size of the string minus one

The size of the string minus one

Once a string is created, it cannot be changed. T or F

True

The repetition operator ( *) works with strings as well as with lists. T or F

True

The substring argument is a string. The method returns true if the string ends with substring.

endswith(substring)

This string method returns true if a string contains only numeric digits and is at least one character in length. a. the digit method b. the isdigit method c. the numeric method d. the isnumber method

the isdigit method

Returns a copy of the string with all alphabetic letters converted to uppercase. Any character that is already uppercase, or is not an alphabetic letter, is unchanged.

upper( )


Ensembles d'études connexes

Mkt300 Quiz Questions Final Exam

View Set