Chapter 8 Flashcards Preview

CSC 110 > Chapter 8 > Flashcards

Flashcards in Chapter 8 Deck (11)
Loading flashcards...
1
Q

Concatenation

A

Appending one string to the end of another string.

2
Q

Slice

A

Span of items taken from a sequence; also known as substring.

3
Q

in operator

A

You can use the in operator to determine whether one string is contained inside another string.

4
Q

not in operator

A

You can use the not in operator to determine whether one string is NOT contained inside another string.

5
Q

String methods

A

Strings in Python have many types of methods, divided into different types of operations. General format:

stringvar.method(argument)

6
Q

endswith(substring)

A

Checks if the string ends with substring. Returns True or False.

7
Q

startswith(substring)

A

Checks if the string starts with substring. Returns True or False.

8
Q

find(substring)

A

Searches for substring within the string. Returns lowest index of the substring, or if substring is not found, returns -1.

9
Q

replace(old, new)

A

Returns a copy of the new string where old is replaced with new.

10
Q

Repetition operator (*)

A

Makes multiple copies of a string and joins them together. General format:

string_to_copy * n

11
Q

split method

A

Returns a list containing the words in the string. By default, spaces are used as separators. Can specify a different separator by passing it as an argument, e.g. ‘/’.