Day2作业 .

1、判断下列逻辑语句的True,False.

1),1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
答案False
2)not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 
 
2、求出下列逻辑语句的值。

1),8 or 3 and 4 or 2 and 0 or 9 and 7

7

2),0 or 2 and 3 and 4 or 6 and 0 or 3

3

3、下列结果是什么?

1)、6 or 2 > 1

6

2)、3 or 2 > 1

3

3)、0 or 5 < 4

False

4)、5 < 4 or 3

3

5)、2 > 1 or 6

True

6)、3 and 2 > 1

Ture

7)、0 and 3 > 1

False

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

4

4. 简述变量命名规范

5. name = input(“>>>”) name变量是什么数据类型?

字符串数据类型

6. if条件语句的基本结构?

 If 条件:

       执行语句

7. while循环语句基本结构?

While 条件:

      

8. 写代码:计算 1 - 2 + 3 ... + 99 中除了88意外所有数的总和?

count =1
sum=0
while(count <=99):
  if count%2==1:
    sum=sum+count
  else:
    if count ==88:
      count =count +1
      continue
   
sum = sum - count
  count =count+1
print(sum)

9. ⽤户登陆(三次输错机会)且每次输错误时显示剩余错误次数(提示:使⽤字符串格式化)

10. 简述ascii、unicode、utf-8编码关系?

11. 简述位和字节的关系?

12. “⽼男孩”使⽤UTF-8编码占⽤⼏个字节?使⽤GBK编码占⼏个字节?

13. 制作趣味模板程序需求:等待⽤户输⼊名字、地点、爱好,根据⽤户的

名字和爱好进⾏任意现实 如:敬爱可亲的xxx,最喜欢在xxx地⽅⼲

Xxx

14. 等待⽤户输⼊内容,检测⽤户输⼊内容中是否包含敏感字符?如果存在

敏感字符提示“存在敏感字符请重新输⼊”,并允许⽤户重新输⼊并打印。敏感字符:“⼩粉嫩”、“⼤铁锤”

str1=("小粉嫩")
str2=("大铁锤")
comment = input("请输入相关的文字:")
if str1 in comment:
      print('有非法字符,请重新输入')
elif str2 in comment:
    print("有非法字符,请重新输入")
else:
    print('评论成功')

15. 单⾏注释以及多⾏注释?

16. 简述你所知道的Python3和Python2的区别?

1. python 3 比python2 代码更加简洁美观 简单 。 

2. python2 input格式有区别 ,2 位row_input 格式

17. 看代码书写结果:

a = 1>2 or 4<7 and 8 == 8

print(a)

true

18.continue和break区别?

Continue是,遇到continue,结束当前循环继续进行下一个循环 。

Break是跳出整个while循环语句

Day3默写代码:

Bit,Bytes,Kb,Mb,Gb,Tb之间的转换关系。

8bits =1 Byte

1024Bytes =1Kb

1024Kb =1MB

1024MB =1GB

1024GB =1TB

Unicode,utf-8,gbk,每个编码英文,中文,分别用几个字节表示。

Unicode编码16bit

英文: 一个字母 ,2个字节

中文, 一个汉字用两个字节表示

Unicode编码32位

英文: 四个字节表示一个字符

中午:四个字节表示一个汉字

浪费资源

UTF-8 用最少用8位去表示一个字符

英文 :8位 表示一个字符

欧洲文字:16位表示一个字符

中文亚洲文字:24位表示一个汉字

UTF-16 最少用16位表示一个字符或者汉字

Gbk

国标,只能表示汉字,一个中文汉字用16bit表示。

原文地址:https://www.cnblogs.com/mengbin0546/p/8334062.html