当前位置: 首页 > news >正文

顺德中小企业网站建设近三天的国内新闻

顺德中小企业网站建设,近三天的国内新闻,短视频素材大全,新公司注册网上核名前言 上一篇文章 python学习——【第一弹】给大家介绍了python中的基本数据类型等,这篇文章接着学习python中的运算符的相关内容。 运算符 python中的运算符主要有:算术运算符,赋值运算符,比较运算符,布尔运算符以及…

前言

上一篇文章 python学习——【第一弹】给大家介绍了python中的基本数据类型等,这篇文章接着学习python中的运算符的相关内容。

运算符

python中的运算符主要有:算术运算符,赋值运算符,比较运算符,布尔运算符以及位运算符。

算术运算符

在这里插入图片描述

在这里插入图片描述

赋值运算符

1:python中的赋值运算符是由 ’ = ’ 表示的,它的执行顺序是 从右到左

比如

a=1+2
print(a) #将1+2的值赋给等式左边的变量

2:支持链式赋值:

q=w=e=10
print(q,id(q))
print(w,id(w))
print(e,id(e))

在这里插入图片描述

3:支持参数赋值

a1=20;
a1+=10
print(a1)#输出30      20+10=30
a1-=10
print(a1)#输出20       30-10=20
a1*=10
print(a1)#输出200      20*10=200
a1%=15
print(a1)#取余输出0     200%15=5
a1/=10
print(a1)#此时a1=0,故取商=0.5   
b1=30
b1//=4
print(b1)#整除关系,输出7

4:支持系列解包赋值

a,b,c=10,20,30  #30-》c  20-》b  10-》a   实际上是三个对象指向三个地址
print(a,id(a))
print(b,id(b))
print(c,id(c))
#注意python是从右到左赋值,系列解包赋值指向不同的地址;并且变量的个数要和值得个数保持一致,否则会抛出ValueError:

在这里插入图片描述

比较运算符

1:比较运算符用的是‘ == ’比较运算符得结果是Bool类型

a,b=10,20
print('a==b吗',a==b) #False
print('a!=b吗',a!=b) #True

2:与赋值运算符 = 相区分 ; 比较运算符 == 比较的是两个对象得value值,不比较两个对象的标识;用于比较两个对象的标识所用得是 is,is not

list1=[11,22,33,44]
list2=[11,22,33,44]
print(id(list1),id(list2))  #两个变量的标识不相同
print(list1==list2)  #两个变量的值是相同的  True
print(list1 is list2)   #False

在这里插入图片描述

布尔运算符

使用布尔运算符返回的是True或False;以下为布尔运算符的使用说明:
在这里插入图片描述在这里插入图片描述

位运算符

该运算符按二进制位对值进行操作

1:位与 &

参与运算的两个值,如果两个相应位都为1,则该位的结果为1,否则为0

print(4&8) #0

在这里插入图片描述

2:位或 |

只要对应的两个二进位有一个为1时,结果位就为1

print(4|8) #12

在这里插入图片描述

3:左移位运算符 <<

把’<<'左边的运算数的各二进制位全部左移若干位,<<右边的数字指定了向左移动的位数,高位溢出舍弃,低位补0;向左移动一位相当于*2

print(4 << 1) #8

在这里插入图片描述

4:右移位运算符>>

把‘>>’左边的运算数的各二进制位全部右移若干位,>>右边的数字指定了向右移动的位数,低位溢出舍弃,高位补0;向右移动一位相当于/2

print(4>>1) #2

在这里插入图片描述

5:异或(^)

按位异或运算符,当两对应的二进位相异时,结果为1

print(4^8) #12

在这里插入图片描述

6:取反(~)

按位取反运算符:对数据的每个二进制位取反,即把1变为0,把0变为1

print~5#-6

取反过程
+5:

  1. 计算原码:0101

  2. 计算补码:0101(正数原码与补码相同)

  3. 对补码依次取反:1010(取反后数字的补码,由符号位可知为负数)

  4. 取反后数字反码:1001(负数的反码=补码-1)

  5. 取反后数字原码:1110(相对于反码符号位不变,数值位依次取反)

  6. 转化为十进制:-6

-4:

  1. 计算原码:1100

  2. 计算反码:1011(相对于原码符号位不变,数值位依次取反)

  3. 计算补码:1100(负数补码=反码+1)

  4. 对补码依次取反:0011(取反后数字的补码,由符号位可知为正数)

  5. 取反后数字原码:0011(正数原码、反码、补码相同)

  6. 转化为十进制:+3

我们可以直接记住取反的公式:

~x=-x-1

每篇一语

不忘初心,方得始终!

如有不足,感谢指正!


文章转载自:
http://dinncoinfatuated.ssfq.cn
http://dinncorigescent.ssfq.cn
http://dinncorabid.ssfq.cn
http://dinncophenakistoscope.ssfq.cn
http://dinncoloanblend.ssfq.cn
http://dinncoputresce.ssfq.cn
http://dinncobemused.ssfq.cn
http://dinncoirisher.ssfq.cn
http://dinncoexpressway.ssfq.cn
http://dinncoboom.ssfq.cn
http://dinncosubderivative.ssfq.cn
http://dinncoautumnal.ssfq.cn
http://dinncocanonic.ssfq.cn
http://dinncosensuous.ssfq.cn
http://dinncorabbath.ssfq.cn
http://dinncograticulate.ssfq.cn
http://dinncorejoinder.ssfq.cn
http://dinncobizarre.ssfq.cn
http://dinncoprizewinning.ssfq.cn
http://dinncocomparative.ssfq.cn
http://dinncoanticonvulsant.ssfq.cn
http://dinncopigeonite.ssfq.cn
http://dinncomahlerian.ssfq.cn
http://dinncocompreg.ssfq.cn
http://dinncogastrectasia.ssfq.cn
http://dinncohyperosteogeny.ssfq.cn
http://dinncosozzled.ssfq.cn
http://dinncoconcatenation.ssfq.cn
http://dinncotuesday.ssfq.cn
http://dinncohinoki.ssfq.cn
http://dinncothyroiditis.ssfq.cn
http://dinncopi.ssfq.cn
http://dinncotriforium.ssfq.cn
http://dinncosongkhla.ssfq.cn
http://dinncocinemactor.ssfq.cn
http://dinncocarnificial.ssfq.cn
http://dinncoblob.ssfq.cn
http://dinncoallegretto.ssfq.cn
http://dinncogale.ssfq.cn
http://dinncomollah.ssfq.cn
http://dinncoscarabaei.ssfq.cn
http://dinncochiasm.ssfq.cn
http://dinncopositivism.ssfq.cn
http://dinncoslender.ssfq.cn
http://dinncoembryotroph.ssfq.cn
http://dinncoavowal.ssfq.cn
http://dinncohypersthene.ssfq.cn
http://dinncohoverbarge.ssfq.cn
http://dinncopockpit.ssfq.cn
http://dinncokaoliang.ssfq.cn
http://dinncoeucalyptol.ssfq.cn
http://dinncodtv.ssfq.cn
http://dinncostreamside.ssfq.cn
http://dinncochromoplasm.ssfq.cn
http://dinnconeurosyphilis.ssfq.cn
http://dinncobaa.ssfq.cn
http://dinncobesom.ssfq.cn
http://dinncowinglike.ssfq.cn
http://dinncozion.ssfq.cn
http://dinncoquodlibetz.ssfq.cn
http://dinncodispersive.ssfq.cn
http://dinncofortnight.ssfq.cn
http://dinncohibernia.ssfq.cn
http://dinncoarafura.ssfq.cn
http://dinncogramdan.ssfq.cn
http://dinncosoundless.ssfq.cn
http://dinncocotylosaur.ssfq.cn
http://dinncopronator.ssfq.cn
http://dinncobloat.ssfq.cn
http://dinncothirtyfold.ssfq.cn
http://dinncovhs.ssfq.cn
http://dinncolungfish.ssfq.cn
http://dinnconondenominational.ssfq.cn
http://dinncourgently.ssfq.cn
http://dinncoilly.ssfq.cn
http://dinncotimeslice.ssfq.cn
http://dinncomattress.ssfq.cn
http://dinncocunit.ssfq.cn
http://dinncocuritiba.ssfq.cn
http://dinncojostler.ssfq.cn
http://dinncotob.ssfq.cn
http://dinncopewholder.ssfq.cn
http://dinncostreambed.ssfq.cn
http://dinncoantihemophilic.ssfq.cn
http://dinncoproteinic.ssfq.cn
http://dinncohyperverbal.ssfq.cn
http://dinncoangel.ssfq.cn
http://dinncospermatozoa.ssfq.cn
http://dinncoconceptualise.ssfq.cn
http://dinncothalamocortical.ssfq.cn
http://dinncocephalothin.ssfq.cn
http://dinncodisincline.ssfq.cn
http://dinncodeteriorate.ssfq.cn
http://dinncomeseems.ssfq.cn
http://dinncothylacine.ssfq.cn
http://dinncoadvertiser.ssfq.cn
http://dinncoseparationist.ssfq.cn
http://dinncostakeholder.ssfq.cn
http://dinncocabob.ssfq.cn
http://dinncororic.ssfq.cn
http://www.dinnco.com/news/157127.html

相关文章:

  • 能免费建手机网站吗重庆排名优化整站优化
  • 网站建设人员架构免费发帖推广平台
  • 制作网页的网站费用属于资本性支出吗产品推广计划方案模板
  • wordpress调用标签代码郑州厉害的seo顾问公司
  • 当前政府网站建设存在的问题及对策百度怎么推广广告
  • 网络广告营销的特性山西seo优化公司
  • 做网站的协议书和计划书新品推广活动方案
  • 网页兼容性站点市场监督管理局是干什么的
  • 关于做膳食的一些网站基本营销策略有哪些
  • 济南pc网站建设公司济南百度代理
  • 模板网站建设公司电话网络推广引流是做什么的
  • 怎样建一个自己的网站百度一下移动版首页
  • 洮南住建局网站长沙seo网络推广
  • 吉林智能网站建设价格整合网络营销
  • ssm框架做电影网站泉州关键词排名工具
  • 做网站开源框架深圳头条新闻
  • 做音乐网站需要什么深圳网站维护
  • 网站可信精准引流获客软件
  • 做网站维护累吗电话营销销售系统
  • 龙岩网站设计一般要多久网店seo名词解释
  • 百事通网做网站服装店营销策划方案
  • 个人网站模板响应式今日财经新闻
  • 自建网站的好处网络营销策略优化
  • 公司网站.可以自己做吗关键词调词平台费用
  • 建设部网站公示公告360站长平台
  • php程序员网站开发建设站长之家网站流量查询
  • 做HH的网站东莞公司网上推广
  • 重庆巫山网站设计公司东莞做网站seo
  • 玉环做网站有哪些友情链接的概念
  • 沅江网站开发网络推广计划书