birth_age = input("Birth year: ") # 获取的是一串字符 print(type(birth_age)) age = 2024 - int(birth_age) # 区别于其他语言的类型转换 类型(内容) print(type(birth_age)) # 可以看到没有改变birth_age自身的类型 如果要改变参照下面两行 # birth_age=int(birth_age) # print(type(birth_age)) print(type(age)) print(age)练习:获取体重,输出转为kg
user_weight = input("Weight : ")
weight = float(user_weight) / 2.0
print("your weight is : "+weight+" kg")