python 第2课 数据类型之number

print("python数字包括整数(int/integer)和浮点数(float)两种类型")
print("加(+)减(-)乘(*)除(/)")
print("乘方(**)求模(%)整除(//);py2整除(/)")
print("浮点数的不确定性:")
print("0.2"+"+"+"0.1"+"="+str(0.2+0.1))
print("3"+"*"+"0.1"+"="+str(3*0.1))

print("用户输入")
message=input("Tell me something, and I will repeat it back to you: ")
print(message)
print("接收的输入信息默认是字符串,要接收其他数据类型,需要在接收后进行类型转换。")
num=input("please input a number:")
print("直接接收,num的类型是:",type(num))
num=int(num)
print("转换类型后,num的类型是:",type(num))
print("注意:在python2.7中,应该使用raw_input()函数接收输入")

原文地址:https://www.cnblogs.com/chuanzi/p/8985403.html