Python Data types and purposes Flashcards

1
Q

What is a complex???

A

Represents complex numbers, consisting of a real part and an imaginary part.
Example: x = 3 + 4j

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

What is a list???

A

Ordered collection of items that can be of different types. Lists are mutable, meaning their elements can be changed after creation.
Example: my_list = [1, 2, ‘hello’, True]

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

What is a Tuple???

A

Ordered collection of items similar to a list, but tuples are immutable, meaning their elements cannot be changed after creation.
Example: my_tuple = (1, 2, ‘hello’, True)

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

What is a range???

A

Represents a sequence of numbers and is commonly used for looping a specific number of times.
Example: my_range = range(0, 10)

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

What is a dictionary(dict)???

A

Collection of key-value pairs. Dictionaries are unordered, mutable, and can contain items of different data types.
Example: my_dict = {‘name’: ‘John’, ‘age’: 30, ‘city’: ‘New York’}

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

What is a set???

A

Unordered collection of unique elements. Sets do not allow duplicate items.
Example: my_set = {1, 2, 3, 4}

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

What is a frozenset???

A

Frozen Set (frozenset): Immutable version of a set. Once created, the elements of a frozenset cannot be changed.
Example: my_frozenset = frozenset({1, 2, 3})

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

What is a bool???

A

Represents Boolean values, which can be either True or False.
Example: is_valid = True

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

What is a bytes???

A

Represents a sequence of bytes. Bytes objects are immutable, similar to tuples.
Example: my_bytes = b’hello’

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

What is a memory view???

A

Provides a view of the memory occupied by an object. It allows for manipulation and interpretation of raw data.
Example: my_memory_view = memoryview(b’hello’)

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

What is a none type???

A

Represents the absence of a value or a null value. Used to indicate that a variable or expression does not have a value assigned to it.
Example: x = None

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