1)整数
1)加减乘除 乘方(**)组合运算
>>> 2+3
5
>>> 3-2
1
>>> 2*3
6
>>> 3/2
1.5
>>> 3**2
9
>>> 3**3
27
>>> 2+3*4
14
>>> (2+3)*4
20
二:浮点数
有时候小数位数可能不确定
>>> 0.1+0.1
0.2
>>> 0.2+0.2
0.4
>>> 2*0.1
0.2
>>> 2*0.2
0.4
>>> 2/0.2
10.0
>>> 0.2+0.1
0.30000000000000004
>>> 3*0.1
0.30000000000000004
三:与字符串结合输出
需要调用str()方法:让python非字符串值表示为字符串
age=23
message="Happy"+str(age)+"rd Birthday"
print(message)
输出
Happy23rd Birthday
如果直接使用age就会报错
age=23
message="Happy"+age+"rd Birthday"
print(message)
message="Happy"+age+"rd Birthday"
TypeError: can only concatenate str (not "int") to str