Data Type Flashcards

1
Q

Integers

A
  • int
  • Whole numbers, such as: 3 300 200
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Floating point

A
  • float
  • Numbers with a decimal pint: 2.3. 4.6. 100.0
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Strings

A
  • str
  • ordered sequence of characters: “hello” ‘Sammy’ “2000”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Lists

A
  • list
  • Ordered sequence of objects: [10,”hello”,200.3]
  • In brackets []
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Dictionaries

A
  • dict
  • In { }
  • Unordered Key:Value pairs: {“mykey”:”value”,”name”:”Frankie”}
  • thisdict = {“brand”: “Ford”, “model”: “Mustang”, “year”: 1964}
    print(thisdict[“brand”])
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Tuples

A
  • tup ( )
  • thistuple = (“apple”, “banana”, “cherry”)
    print(thistuple)
  • Ordered immutable sequence of objects: (10,”hello”,200.3)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Sets

A
  • Braces {}
  • set
  • myset = {“apple”, “banana”, “cherry”}
  • Unordered collection of unique objects: {“a”,”b”}
  • Note: Set items are unchangeable, but you can remove items and add new items.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Booleans

A
  • bool
  • Logical value indicating True or False
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Text Type

A

str

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

Numeric Types

A
  1. int
  2. float
  3. complex
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Sequence Types

A
  1. list
  2. tuple
  3. range
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Mapping Type

A

dict

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

Set Types

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

Boolean Type

A

bool

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

Binary Types

A
  • bytes
  • bytearray
  • memoryview
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Brackets [] used for:

A
  • List
  • List comprehensions
17
Q

Braces {} used for:

A
  • Sets eg. s1={10,20,30}
  • Dictionary eg. d1={‘roll’:101, ‘name’:’xyz’}
18
Q

Parentheses() used for:

A
  • Immutable sequenced data type (data that doesn’t change)
  • t1=(10,20,30)
19
Q
  • brackets []
  • braces {}
  • parenthese ()
A
  • list
  • sets
  • tup
20
Q
  • list
  • sets
  • tup
A
  • brackets []
  • braces {}
  • parenthese ()
21
Q

Get the data type of any object:

A
  1. type()
  2. print(type(x))
22
Q

Setting the Data Type:

x = “Hello World”

A

str

23
Q

Setting the Data Type:

x = 20

A

int

24
Q

Setting the Data Type:

x = 20.5

A

float

25
Q

Setting the Data Type:

x = 1j

A

complex

26
Q

Setting the Data Type:

x = [“apple”, “banana”, “cherry”]

A

list

27
Q

Setting the Data Type: x = (“apple”, “banana”, “cherry”)

A

tuple

28
Q

Setting the Data Type:

x = range(6)

A

range

29
Q

Setting the Data Type:

x = {“name” : “John”, “age” : 36}

A

dict

30
Q

Setting the Data Type:

x = {“apple”, “banana”, “cherry”}

A

set

31
Q

Setting the Data Type:

x = frozenset({“apple”, “banana”, “cherry”})

A

frozenset

32
Q

Setting the Data Type:

x = True

A

bool

33
Q

Setting the Data Type:

x = b”Hello”

A

bytes

34
Q

Setting the Data Type:

x = bytearray(5)

A

bytearray