少说话多写代码之Python学习026——条件语句03(比较运算符)

栏目: Python · 发布时间: 6年前

内容简介:版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yysyangyangyangshan/article/details/83216798

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yysyangyangyangshan/article/details/83216798

条件语句中基本的运算符就是比较运算符。常用的运算符如下:

==,

<,

>,

<=,

>=,

!=,

is ,

is not, 

in,

not in。

具体用法如下,

x=1
y=1
if x==y :
    print('x等于y')

x=1
y=2
if x<y:
    print('x小于y')

x=3
y=2
if x>y:
    print('x大于y')

x=3
y=3
if x>= y :
    print('x大于等于y')

x=3
y=4
if x<= y :
    print('x小于等于y')

x=5
y=15
if x!=y :
    print('x不等于y')

x=y=1
if x is y:
    print('x和y是同一个对象')

x=1
y=2
if x is not y :
    print('x和y不是同一个对象')

x=90
y={80,90,100}
if x in y:
    print('x是y的成员')

x=250
y={80,90,100}
if x not in y:
    print('x不是y的成员')

输出

x等于y
x小于y
x大于y
x大于等于y
x小于等于y
x不等于y
xy是同一个对象
xy不是同一个对象
xy的成员
x不是y的成员

工程文件下载: https://download.csdn.net/download/yysyangyangyangshan/10734298


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Scalable Internet Architectures

Scalable Internet Architectures

Theo Schlossnagle / Sams Publishing / 2006-7-31 / USD 49.99

As a developer, you are aware of the increasing concern amongst developers and site architects that websites be able to handle the vast number of visitors that flood the Internet on a daily basis. Sc......一起来看看 《Scalable Internet Architectures》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试