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

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

内容简介:版权声明:本文为博主原创文章,未经博主允许不得转载。 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
x和y是同一个对象
x和y不是同一个对象
x是y的成员
x不是y的成员

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


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

查看所有标签

猜你喜欢:

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

Foundation Web Standards

Foundation Web Standards

Jonathan Lane、Steve Smith / Friends of ED / 21st July 2008 / $34.99

Foundation Web Standards explores the process of constructing a web site from start to finish. There is more to the process than just knowing HTML! Designers and developers must follow a proper proces......一起来看看 《Foundation Web Standards》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码