1.加+,減-,乘*,除/spa
例如:code
a = 1 b = 2 c = a + b print(c)
運算結果:blog
3
Process finished with exit code 0
a = 1 b = 2 c = a - b print(c)
運算結果:字符串
-1
Process finished with exit code 0
a = 1 b = 2 c = a * b print(c)
運算結果:it
2
Process finished with exit code 0
a = 1 b = 2 c = a / b print(c)
運算結果:class
0.5
Process finished with exit code 0
2.特殊的 冪 **, 取餘%,//取商error
例如:di
a = 1 b = 2 c = a ** b print(c)
運算結果:co
1
Process finished with exit code 0
a = 9 b = 2 c = a % b print(c)
運算結果:字符
1
Process finished with exit code 0
a = 9 b = 2 c = a // b print(c)
運算結果:
4
Process finished with exit code 0
3.in 和 not in 表示判斷
判斷某個東西是否在**裏
例如:
in
name = 'abd' #'abd' 字符串 ; 'a' 字符 if 'a' in name: # 若是a在name裏 print('ok') else: print('error')
運行結果:
ok
Process finished with exit code 0
ps:
子字符串:
name = 'abd' #'abd' 字符串 ; 'a' 字符 #'bd' 子字符串或者叫子序列 if 'ad' in name: # 若是a在name裏 print('ok') else: print('error')
運行結果:
error
Process finished with exit code 0
not in:
name = 'abd' if 'a' not in name: print('ok') else: print('error')
運行結果:
error
Process finished with exit code 0