5 Star 28 Fork 14

极客挖掘机/python-learning

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Demo-1.py 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
# 对应《小白学 Python(6):基础运算符(下)》示例代码
a = 10
b = 20
c = a + b
print("c = a + b 的值为:", c)
c += a
print("c += a 的值为:", c)
c *= a
print("c *= a 的值为:", c)
c /= a
print("c /= a 的值为:", c)
c = 2
c %= a
print("c %= a 的值为:", c)
c **= a
print("c **= a 的值为:", c)
c //= a
print("c //= a 的值为:", c)
print(True and True)
# True
print(True and False)
# False
print(True or True)
# True
print(True or False)
# True
print(False or False)
# False
print(not True)
# False
print(not False)
# True
str = "asdfghjkl"
if 'a' in str:
print('a 在字符串 str 中')
else:
print('a 不在字符串 str 中')
if 'a' not in str:
print('a 不在字符串 str 中')
else:
print('a 在字符串 str 中')
a = 20
b = 20
if a is b:
print("a 和 b 有相同的标识")
else:
print("a 和 b 没有相同的标识")
if id(a) == id(b):
print("a 和 b 有相同的标识")
else:
print("a 和 b 没有相同的标识")
# 修改变量 b 的值
b = 30
if a is b:
print("a 和 b 有相同的标识")
else:
print("a 和 b 没有相同的标识")
if a is not b:
print("a 和 b 没有相同的标识")
else:
print("a 和 b 有相同的标识")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/inwsy/python-learning.git
git@gitee.com:inwsy/python-learning.git
inwsy
python-learning
python-learning
master

搜索帮助