《笨办法学python》加分习题28——我的答案

本文详细解析了Python中布尔运算符的使用方法,并通过一系列实例展示了不同运算符的应用场景。包括等价运算符如==和!=的用法,以及and、or、not等逻辑运算符的具体操作方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!

文中例题:

True and True

False and True

1 == 1 and 2 == 1

"test"  == "test"

1 == 1 or 2 != 1

True and 1 == 1

False and 0 != 0

True or 1 == 1

"test" == "testing"

1 != 0 and 2 == 1

"test" != "testing"

"test" == 1

not (True and False)

not (1 == 1 and 0 != 1)

not (10 == 1 or 1000 == 1000)

not (1 != 10 or 3 == 4)

not ("testing" == "testing" and "Zed" == "Cool Guy")

1 == 1 and not ("testing" == 1 or 1 == 0)

"chunky" == "bacon" and not (3 == 4 or 3 == 3)

3 == 3 and not ("testing" == "testing" or "Python" == "Fun")

运行结果:

这里写图片描述

习题答案:

1 和 2、

等价运算符名称
==equal
!=not equal
<>not equal
>great than
>=great or equal
<less than
<=less or equal
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值