python学习-10 运算符1
2020-12-13 01:56
标签:序列 pytho erro bsp python name RoCE 子序列 with 1.加+,减-,乘*,除/ 例如: 运算结果: 运算结果: 运算结果: 运算结果: 2.特殊的 幂 **, 取余%,//取商 例如: 运算结果: 运算结果: 运算结果: 3.in 和 not in 表示判断 判断某个东西是否在**里 例如: in 运行结果: ps: 子字符串: 运行结果: not in: 运行结果: python学习-10 运算符1 标签:序列 pytho erro bsp python name RoCE 子序列 with 原文地址:https://www.cnblogs.com/liujinjing521/p/11020423.htmla = 1
b = 2
c = a + b
print(c)
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)
2
Process finished with exit code 0
a = 1
b = 2
c = a / b
print(c)
0.5
Process finished with exit code 0
a = 1
b = 2
c = a ** b
print(c)
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
name = ‘abd‘ #‘abd‘ 字符串 ; ‘a‘ 字符
if ‘a‘ in name: # 如果a在name里
print(‘ok‘)
else:
print(‘error‘)
ok
Process finished with exit code 0
name = ‘abd‘ #‘abd‘ 字符串 ; ‘a‘ 字符
#‘bd‘ 子字符串或者叫子序列
if ‘ad‘ in name: # 如果a在name里
print(‘ok‘)
else:
print(‘error‘)
error
Process finished with exit code 0
name = ‘abd‘
if ‘a‘ not in name:
print(‘ok‘)
else:
print(‘error‘)
error
Process finished with exit code 0