Chapter 6: Strings Flashcards

1
Q

A variable used to count something, usually initialized to zero and then incremented.

A

counter

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

A string with no characters and length 0, represented by two quotation marks.

A

empty string

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

A boolean variable used to indicate whether a condition is true or false.

A

flag

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

A statement that calls a method.

A

invocation

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

The property of a sequence whose items cannot be assigned.

A

immutable

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

An integer value used to select an item in a sequence, such as a character in a string.

A

index

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

One of the values in a sequence.

A

item

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

A function that is associated with an object and called using dot notation.
eg. string.upper()

A

method

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

Something a variable can refer to. For now, you can use it and “value” interchangeably.

A

object

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

A pattern of traversal that stops when it finds what it is looking for.

A

search

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

An ordered set; that is, a set of values where each value is identified by an integer index.

A

sequence

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

A part of a string specified by a range of indices.

A

slice

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

To iterate through the items in a sequence, performing a similar operation on each.

A

traverse

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

Contains both data (the actual string itself) and methods, which are effectively functions that are built into it and are available to any instance of it.

A

object

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

boolean operator that takes two strings and returns True if the first appears as a substring in the second

A

in
eg. ‘a’ in ‘banana’

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

function that lists object methods

17
Q

string method that makes everything uppercase

18
Q

string method that makes everything lowercase

19
Q

string method that makes first letter uppercase

A

.capitalize()

20
Q

string method that searches for the position of one string within another. Returns index value

A

.find(string, starting index)

21
Q

string method that removes whitespace or substring argument from both ends

A

.strip()
.strip(substring)

22
Q

string method that returns True or False if substring matches beginning of string
argument must match case

A

.startswith(string)

23
Q

Allows Python expressions to be used within string literals. Accomplished by prepending an f to the string literal and enclosing expressions in curly braces {}

A

formatted string literals / f-string
eg. camels = 42
f’I have {camels} camels’ = ‘I have 42 camels’

24
Q

function to get more information about a string method

A

help()
eg. help(string.method)

25
x%=1
gives remainder of x divided by value each loop. Doesn't update variable after first loop
26
string method that removes whitespace or substring argument from right side
.rstrip(string)
27
string method that removes whitespace or substring argument from left side
.lstrip(string)
28
string comparison order
CAPITAL < lowercase
29
The binding of data and functions (or behavior)
encapsulation
30
%s
string format operator s = 'What... is your favourite colour? %s. Go on. Off you go.' %(input())
31
%d
decimal format operator