Lecture 8 Flashcards

1
Q

What is a Collection Data Type?

A

Stores multiple items in a single variable.

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

What are the Four different Collection Data Types?

A

List

Tuple

Dictionary

Set

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

Tuple

A

Tuples are used to store multiple items in a single variable.

Tuple is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Set, and Dictionary, all with different qualities and usage.

A tuple is a collection which is ordered and unchangeable.

Tuples are written with round brackets.

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

Tuple Items

A

Tuple items are ordered, unchangeable, and allow duplicate values.

Tuple items are indexed, the first item has index [0], the second item has index [1] etc.

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

Tuple Ordered

A

When we say that tuples are ordered, it means that the items have a defined order, and that order will not change.

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

Tuple are changeable True or False

A

Tuples are unchangeable, meaning that we cannot change, add or remove items after the tuple has been created.

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

Do Tuples Allow Duplicates?

A

Since tuples are indexed, they can have items with the same value:

Exp:

thistuple = (“apple”, “banana”, “cherry”, “apple”, “cherry”)
print(thistuple)

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