02-数据转换答案
1.使⽤print ()输出函数,分别打印输出三种数据类型(字符串、整形、浮点型)的内容,并使⽤t ype()函数查看所打印的内容属于什么类型?
答案:
2.有字符串`num = '99.9'`,将num转化为整形
答案:
3.已知有如下变量:
答案:
4.已知有如下变量:
答案:
print('你好', type('你好')) # 1
print(99, type(99)) # 2
print(3.14, type(3.14)) #
3num = '99.9'1
new_num = int(float(num))
2weight = 1001
height = "99.0"2
3
要求使用print()输出函数,转换数据类型后输出的结果为:199
4weight = 1001
height = "99.0"2
print(weight + int(float(height)))
3weight = 100.51
height = "200.1"2
要求使用print()输出函数,转换数据类型后输出的结果为:100.5200.1
3weight = 100.51
height = "200.1"2
print(str(weight) + height)3