判断下列逻辑语句的True,False.
1)1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
1 > 1 or 3 < 4 or F and 9 > 8 or 7 < 6
1 > 1 or 3 < 4 or F or 7 < 6
T or F or 7 < 6
True
2)not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
F or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
F or F and 9 > 8 or 7 < 6
F or F or 7 < 6
False
2、求出下列逻辑语句的值。
1),8 or 3 and 4 or 2 and 0 or 9 and 7
8 or 4 or 2 and 0 or 9 and 7
8 or 4 or 0 or 9 and 7
8 or 4 or 0 or 7
8 or 0 or 7
8 or 7
8
2),0 or 2 and 3 and 4 or 6 and 0 or 3
0 or 3 and 4 or 6 and 0 or 3
0 or4 or 6 and 0 or 3
0 or4 or 0 or 3
4 or 0 or 3
4 or 3
4
3、下列结果是什么?
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
Ture
6)、3 and 2 > 1
True
7)、0 and 3 > 1
0
8)、2 > 1 and 3
True
9)、3 > 1 and 0
0
10)、3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2
2 or 2 < 3 and 3 and 4 or 3 > 2
2 or 3 and 3 and 4 or 3 > 2
2 or3 and 4 or 3 > 2
2 or 4 or 3 > 2
2 or 3 > 2
2
4. 简述变量命名规范
1,由字母、数字、下划线,组成
2,开头不能是数字
3不能是Python的关键字
4不能太长,要有描述性,最好是下划线类型
5. name = input(“>>>”) name变量是什么数据类型?
字符串
6. if条件语句的基本结构?
if 条件:
结果
7. while循环语句基本结构?
while 条件:
结果
8. 写代码:计算 1 - 2 + 3 ... + 99 中除了88以外所有数的总和?
count = 0
sum = 0
while count < 99:
count +=1
if count % 2 ==1:
sum += count
else:
if count ==88:
continue
else:
sum -= count
print(sum)
9. ⽤户登陆(三次输错机会)且每次输错误时显示剩余错误次数(提示:使⽤字符串格式化)
count=3
while count>0:
name = input("姓名")
password = input("密码")
if name=="111"and password=='222':
print('登录成功')
break
else:
count -= 1
print('姓名或者密码错误', '您还有%d次机会' % count)
continue
10. 简述ascii、unicode、utf-8编码关系?
ASCII是最早的编码,Unicode是在其基础上发明的,涵盖更全,uft-8在Unicode的基础上优化了很多,更简洁。
11. 简述位和字节的关系?
8位=1字节
12. “⽼男孩”使⽤UTF-8编码占⽤⼏个字节?使⽤GBK编码占⼏个字节?
9 6
13. 制作趣味模板程序需求:等待⽤户输⼊名字、地点、爱好,根据⽤户的名字和爱好进⾏任意现实 如:敬爱可亲的xxx,最喜欢在xxx地⽅⼲xxx
name =input("姓名")
add=input('地址')
hobby= input('爱好')
msg='敬爱可亲的%s,最喜欢在%s地⽅⼲%s'%(name,add,hobby)
print(msg)
14. 等待⽤户输⼊内容,检测⽤户输⼊内容中是否包含敏感字符?如果存在敏感字符提示“存在敏感字符请重新输⼊”,并允许⽤户重新输⼊并打印。敏感字符:“⼩粉嫩”、“⼤铁锤”
while True:
comment = input('请输入')
if '小粉嫩'or '大铁锤'in comment:
print('存在敏感字符请重新输⼊')
continue
15. 单⾏注释以及多⾏注释?
单行#,多行'''1''' """!"""
16. 简述你所知道的Python3和Python2的区别?
python2: 复杂、默认ascii、raw input 、 print() 或者 print '内容'
python3:简介、默认uft-8、inpue、print('内容')
17. 看代码书写结果:
a = 1>2 or 4<7 and 8 == 8
print(a)
True
18.continue和break区别?
break跳出,结束循环
continue只跳出本次循环
Day3默写代码:
Bit,Bytes,Kb,Mb,Gb,Tb之间的转换关系。
Unicode,utf-8,gbk,每个编码英文,中文,分别用几个字节表示。