CH3 - Introducing Lists Flashcards

1
Q

What is a List?

A

A collection of items in a particular order.

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

What symbol represents a list in Python?

A

Square brackets [ ].

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

How to name a List?

A

Using plurals, for example: (Names)

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

How are elements separated in a List?

A

By using commas.

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

How is the position counted within a List?

A

Index.

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

Start of an Index?

A

0.

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

Last element of the index?

A

-1, or last positive index count.

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

Are methods supported in Lists?

A

Yes.

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

Are F-strings supported in Lists?

A

Yes.

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

Are List dynamic or static?

A

Dynamic.

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

How to replace elements in a list?

A

Index position, and value.

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

What is .append()?

A

A method in Python, That adds elements to the end of the list.

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

What is .insert()?

A

A method in Python, That inserts elements to any position of the list.

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

What is a simple way to add an element to a list?

A

By using the .append() method.

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

How to add an element to the end of a list?

A

By using the .append() method.

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

How to remove an element from the list using index position?

A

By using a del statement.

17
Q

Does the del statement remove elements temporally or permanently?

A

permanently.

18
Q

What is .pop()?

A

A method in Python that removes the last element from the list.

19
Q

What is .pop(3)?

A

A method in Python that removes the 4th element from the list.

20
Q

What is .remove(‘jim’)?

A

A method in Python that removes the ‘jim’ element from the list.

21
Q

What happens when they are multiple elements with the same value in a list, and the .remove() method is used?

A

Only the 1st occurrence of the value is deleted.

22
Q

What is .sort()?

A

A method in Python, That changes the order of the list alphabetically.

23
Q

Does the .sort() method change the elements temporally or permanently?

A

permanently.

24
Q

What is reverse = True?

A

A Python argument you can pass to the .sort() method to change the list in alphabetical order.

25
Q

Are methods applied to a variable or value?

A

Variable.

26
Q

Will a method change the elements temporally or permanently?

A

permanently.

27
Q

What are the functions in Python?

A

Used to temporally display elements in a list.

28
Q

What is .reverse()?

A

A method in Python, That rearranges the list in chronological order.

29
Q

What is len()?

A

A function in Python that counts the elements in a list.