strings Flashcards

1
Q

str(x)

A

convert input to string

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

title()

A

returns a copy of the string in which first characters of all the words are capitalized

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

print(‘Hello, %s’ % name)

A

positional formatting

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

print(‘Hello, {}’.format(name))

A

string literals

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

print(f’Hello, {name}!’)

A

formatted strings

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

from string import Template

t = Template(‘Hey, $name!’)
print(t.substitute(name=name))

A

Template strings

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