Typecasting Flashcards

(3 cards)

1
Q

What is type casting?

A

Type casting is converting a data type of a value to another type.

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

How would you program a int to a float?

A

x=1
print(float(x))

twd: 1.0

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

If

x=4
y=3.0
z=”8”

How would I make z into an int?

A

x is an int
y is a float
z is a str

z=int(z)

twd: 8

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