Strings & Text Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a string?

A

a sequence of characters

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

what are characters?

A

letters, numbers, punctuation marks, spaces

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

How are string literals specified

A

enclosing a sequence on characters with either single or double quotations

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

why are both double and single quotations able to be used?

A

able to use apostrophe or quotation marks within the string

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

what is string length?

A

number of characters in a string

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

what is the string length function?

A

len()

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

how can you convert numbers into a string?

A

str()

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

what is string concatenation?

A

adding one string onto the end of another with “+”

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

how do you follow nested function calls?

A

start from inner most to outermost function and substitute values

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

what is operator overloading? what is an example of it?

A

operator performs different functions of variables of different types (ex. ‘+’, ‘*’)

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

what is string repetition function?

A

“*” repeats a string as many times as indicated:

dashes = “-“*4
–> output: —-

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

why is it important to have the str() function?

A

you can now combine numbers with strings (49ers)

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

what does python use for characters?

A

unicode –> characters are stored as integer values

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

what is an index number?

A

the character’s assigned number, starting with 0

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

what is index number operator?

A

[ ]

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

what is an object?

A

software entity that represents a value with certain behaviour
–> string, graphical window, data file

17
Q

what are methods?

A

behaviour of an object - similar to a function

18
Q

how is a method different from a string?

A

methods can only be applied to an object of the type for which it was defined while functions are general and can accept arguments of different types

19
Q

how do you print a double quote?

A

before each “ put a “" for the quotation inside

20
Q

how do you print a backslash?

A

before \ print another \

21
Q

do do you output a new line?

A

\n