首页 > 编程语言 > 详细

Python_day02_2018.7.3

时间:2018-07-03 21:27:36      阅读:207      评论:0      收藏:0      [点我收藏+]

一.格式化输出

print("%s今年%s岁,爱好是%s,性别是:%s"  %  (name,age,hobby,gender))

%s 叫做占位符,(字符串) 

%d叫做占位符,(整型,数字)

二.基本运算符

1.算数运算

+ 加 10+20=30

- 减  20-10= 10

* 乘 10*10=100

/ 除法   3/2=1.3

% 取余 3/%2=1

// 商取整 3//2=1

2.比较运算

= 等于

!= 不等于    <>  也是不等于

> 大于

<小于

>= 大于等于

<=小于等于

3.赋值运算

a=10

b=20

4.逻辑运算

not:真假反过来

and :同真为真,有假为假

or  :有真为真,全假为假

运算顺序:  not =>and => or

1)1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6  ==> True
# 2)not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 ==>Flase

1),8 or 3 and 4 or 2 and 0 or 9 and 7  ==>8
# 2),0 or 2 and 3 and 4 or 6 and 0 or 3 ==>4

 1)、6 or 2 > 1   ==>6
# 2)、3 or 2 > 1 ==>3
# 3)、0 or 5 < 4 ==>Flase
# 4)、5 < 4 or 3 ==>3
# 5)、2 > 1 or 6 ==>True
# 6)、3 and 2 > 1 ==>True
# 7)、0 and 3 > 1 ==>0
# 8)、2 > 1 and 3 ==>3
# 9)、3 > 1 and 0 ==>0
# 10)、3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2 ==>2

 

Python_day02_2018.7.3

原文:https://www.cnblogs.com/kcwxx/p/9260526.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!