Unit 9 : String Flashcards

1
Q

What is string?

A
  1. A sequence of characters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What uses to configure strings values? ( 2 )

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

What does + means in python?

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

What are the type for number in strings?

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

How can we convert numbers in string into integer?

A
  1. Using int()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can we get single character from a string variable?

A
  1. Using an index specified in square brackets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the rules for index value? ( 2 )

A
  1. The index value must be an integer and starts at zero
  2. The index value can be an expression that is computed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What will we get when we attempt to inde beyond the end of a sting

A
  1. Get a python error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can we loop through string?

A

fruit = “banana”
index = 0
while index < len(fruit):
letter = fruit[index]
print(index, letter)
index = index + 1

for letter in fruit:
print(letter)

while index < len(fruit):
letter = fruit[index]
print(letter)
index += 1

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

How can we get the length of a string?

A
  1. len() function

fruit = “banana”

print(len(fruit)) # 6

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