String Methods Flashcards

(12 cards)

1
Q

What does len stand for?

A

Length, like the length of your name can be found by the following:

name= “Meeko”
print(len(name))

TWD: 5

This is the length method for str methods

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

How do you find a character within a str?

A

name= “Meeko”
print(name.find(“e”))

TWD 1

M=0
e=1
e=2
k=3
o=4
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you capitalize?

A

name=”meeko”
print(name.capitalize())

TWD Meeko

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

How do you uppercase?

A

name=”meeko”
print(name.upper())

TWD: MEEKO

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

How do you lowercase?

A

name=”Meeko”
print(name.lower())

TWD: meeko

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

How do you find if something is a digit?

A

name=123
print(name.isdigit())

TWD: True

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

Isalpha?

A

Are these alphabetical characters. Cannot have any spaces if you want it to be true (only has letters)

name=”meeko”
print(name.isalpha())

TWD: True

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

What is the count str method used for?

A

Count is used to count how many characters are within your str

name=”Meeko”
print(name.count())

TWD: 5

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

Write a code to count how many S’s are in Mississippi

A

name=”Mississippi”
print(name.count(“s”))

TWD: 4

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

Write a code to count how many S’s are in Mississippi

A

name=”Mississippi”
print(name.count(“s”))

TWD: 4

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

Write a code that replaces all the of S’s to T’s in Mississippi

A

name=”Mississippi”
print(name.replace(“s”,”t”))

TWD: Mittittippi

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

Create a code that will repeat duck 5xs

A

name=”duck

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