Strings Unit 2 Flashcards

(10 cards)

1
Q

What is a string in programming?

A

A string is a sequence of characters, like letters, numbers, or symbols, enclosed in quotes.

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

What does the index value of a string character represent?

A

It represents the position of each character in the string, starting from 0.

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

What function is used to find the number of characters in a string?

A

The built-in length function, e.g. len(string) in Python.

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

What is string traversal?

A

String traversal is using a loop to go through a string character by character.

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

What is iteration in the context of strings?

A

Iteration is repeating an action for each character in a string using a loop.

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

How do you traverse a string using a loop in Python?

A

for char in string:
print(char)

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

What is string concatenation?

A

It is the process of joining two or more strings together.
Example: “Hello” + “ “ + “World” → “Hello World”

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

What is string slicing?

A

Extracting a part of a string using its index values.
Example: text[0:4] → returns characters from index 0 to 3.

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

What is string splitting?

A

Breaking a string into a list of parts using a separator.
Example: “a,b,c”.split(“,”) → [‘a’, ‘b’, ‘c’]

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

What is string formatting?

A

Controlling how text is displayed, such as inserting variables into a string.
Example: f”Hello, {name}!”

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