Unit 11 Flashcards

1
Q

11.1 - String Slicing

What is slice notation?

A

reading multiple characters in a string using my_str[a:b]

my_str = string, a/b = ints

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

11.1 - String Slicing

What is a stride?

A

the number of steps determines how much to increment while parsing the input string

my_str[0:10:2]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

11.2 - Advanced String Formatting

What is field width?

A

the minimum number of characters inserted into the string to print a chart-like display

{'test':16}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

11.2 - Advanced String Formatting

What is an alignment character?

A

determines how a value should be aligned in filed width

left (<), right (>), and centered (^)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

11.2 - Advanced String Formatting

What is a fill character?

A

used in padding “free space” in a string

{score:0>4}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

11.3 - String Methods

What does .replace(a, b) do?

A

copy of a string, all occurrences of a is replaced with b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

11.3 - String Methods

What does .find(a) do?

A

returns the index of the first occurrence in a string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

11.3 - String Methods

What does .count(a) do?

A

returns the number of times a appears in a string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

11.3 - String Methods

What does .isalnum() do?

A

true if all characters are letters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

11.3 - String Methods

What does .isdigit() do?

A

true if all characters are numbers 0-9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

11.3 - String Methods

What does .islower() do?

A

true if all characters are lowercase

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

11.3 - String Methods

What does .isupper() do?

A

true if all characters are uppercase

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

11.3 - String Methods

What does .isspace() do?

A

true if all characters are whitespace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

11.3 - String Methods

What does .startswith(x) do?

A

true if string starts with x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

11.3 - String Methods

What does .endswith(x) do?

A

true if string ends with x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

11.3 - String Methods

What does .capitalize() do?

A

copy of string with only first letter capitalized

17
Q

11.3 - String Methods

What does .lower() do?

A

copy of string with all characters lowercase

18
Q

11.3 - String Methods

What does .upper() do?

A

copy of string with all characters uppercase

19
Q

11.3 - String Methods

What does .strip() do?

A

removes whitespace from a string

20
Q

11.3 - String Methods

What does .title() do?

A

copy of string with all first characters capitalized

21
Q

11.3 - String Methods

What does .split() do?

A

splits a string into a list of tokens

22
Q

11,4 - Splitting and Joining Strings

What is a token?

A

a substring that forms a part of a larger string

23
Q

11,4 - Splitting and Joining Strings

What does .join() do?

A

joins a list of strings together to create a single string

24
Q

11,4 - Splitting and Joining Strings

What does list() do?

A

turns a single argument into a list; can replace .split()

25
Q

11,4 - Splitting and Joining Strings

How do you make a copy of a list?

A

myList[:]