首页 技术 正文
技术 2022年11月19日
0 收藏 863 点赞 4,063 浏览 1122 个字

pycharm 安装设置:

按照百度百科或者官网介绍下载,安装.

激活步骤

1:改host

2.输入激活信息,注意有效期.

python 逻辑运算符://返回的均为bool值

与 and

A and B

或 or

A or B

非 not

not A

格式化输出:

name = input("your name is: ")
age = input("your age is: ")
height = input("your height is: ")
msg = '我叫%s,今年%s,身高%s' % (name, age, height)
print(msg)

转义符 : %% == %while else:如果while没有被break打断就走else; 打断了就不走else, 直接跳出整个循环注意:while 和 else同级;且是把while所有循环走完 再走else

count = 0
while count <= 5:
count += 1
if count == 3:
break
print("Loop",count)else:
print("Loop is succeed over")
print("------ out of the while loop ------")

结果:

python全栈学习 day02

count = 0
while count <= 5:
count += 1
if count == 3:
pass
print("Loop",count)else:
print("Loop is succeed over")
print("------ out of the while loop ------")

结果:

python全栈学习 day02

 运算符: // 整除运算符,返回商的整数部分优先级:比较运算符 > 逻辑运算符优先级: ( ) > not > and > or同一优先级,从左至右运算x or y ; x为真(x非零),则返回x

print(2 or 1)

返回:2

x and y ; x为真(x非零),则返回y

print(2 or 1)

返回结果为: 1

比较运算符和逻辑符合混合运算时: 返回的值看最终运算时的 运算符 决定例子1: 

print(2 or 1 < 3)

分析: 首先看 比较运算符(大于符号: >)优先级更高,所以整理后原式:

print( 2 or False)

根据OR的运算规则,结果返回为:2

例子2:

print(1 > 2 and 3 or 4 and 3 < 2 or not 5)

分析: 依旧是根据优先级,首先计算比较运算符:

print(False and 3 or 4 and False or not 5)

再根据逻辑优先级运算 : not > and > or

print(False and 3 or 4 and False or False)
print(False  or  False or False)

结果为: false

例子3:

print(2 or 1 < 3 and 2)

分析:

第一步:计算比较运算:

print(2 or True and 2)

第二步:计算优先的and:

print(2 or  2)

第三步:计算or出结果:

2

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,991
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,505
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,349
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,134
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,766
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,844