In [2]:
name = "Tony"
age = 43
wage = 12.50
happy_employee = True
In [3]:
#what is the type of name?
type(name)
Out[3]:
In [4]:
#what is the type of age?
type(age)
Out[4]:
In [5]:
# convert age to float
float(age)
Out[5]:
In [6]:
# convert age to float then ask for type
type(float(age))
Out[6]:
In [8]:
# from float to int, you lose decimal places
lost_wage = int(wage)
lost_wage
Out[8]:
In [9]:
# switching types from str to int
name = 99
type(name)
Out[9]:
In [10]:
# ValueError because you cannot convert "Tony" to float
name = "Tony"
float(name)
In [ ]: