7. Data Types Flashcards

1
Q

What is casting ?

A

Casting is when you convert one data type into another data type

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

convert Integer into Real

A

int_value = 10
real_value = float(int_value)

Output = 10.0

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

Convert Real into Integer

A

real_value = 10.4
int_value = int(real_value)

Output = 10

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

Convert String to Integer

A

int_str = “6”
int_value = int(int_str)

Output = 6

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

Convert Integer into String

A

value = 3
str_value = str(value)

Output = “3”

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

Convert Boolean into String

A

bool_value = True
str_value = str(bool_value)

Output = “True”

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

Convert String into Boolean

A

bool_str = “False”
bool_value = bool(bool_str)

Output = “False”

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