Python Flashcards

1
Q

Strings

How can you slice a string?

A

[start index:end Index:Step]

[1:2:2] end index - does not include the provided value

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

command to make all lower casses to upper casses letters

A

.upper()

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

convert lower case to upper and upper to lower case letters

A

.swapcase()

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

converts the first letter to capital letters

A

.capitalize()

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

find a substring of a string

A

some_string.find(what to find)

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

True or false answer - is something in a string

A

‘Searchparameter’ in ‘variable that saves the srting’

‘ing’ in a

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

count the occurence of a substring

A

variable.count(parameter)

a.count(a)

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

replace in substrings

A

.replace(‘what’,’replace with’)

a.replace(‘x’,’y’)

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

string concatinate

A

‘string1’+’string2’=string1string2

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

string repetition

A

3*a evaluates to aaa

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