2.2.2 data types Flashcards

1
Q

what is a string (str)

A

sequence of characters eg. str(“hello world”)

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

what is an integer (int)

A

a number with normal value of number eg. int(“8”)
- needed for accurate answers in arithmetic operations

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

what is character

A

any character that will always be shown as that character

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

what is a float/real (float) or (real)

A

a number with a decimal eg. float(“2.2”)

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

what is boolean (bool)

A

either true or false eg. bool(true)

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

what is casting

A

changing the data type of a value

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

why is casting used

A

data types can only operate with same data types
eg. “hello world” + 2 is not possible
but if age = 2
age = str(age)
then (“hello world”+ age) would return hello world2

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

how to find out what data type a variable is

A

print(type(VariableName))

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