9.简述ASCII、Unicode、utf-8编码
ASCII码:英文和标点字符,8位,1个字符.2**8
Unicode:万国码,32位,4个字符.世界通用.2**32
UTF-8:简化万国码,英文8位1字符,欧洲16位2字符,中文24位3字符.
10.简述位和字节的关系?
8位 为 1个字节
8bit = 1byte
1位代表一个0/1
11.猜年龄游戏
要求:允许用户最多尝试3次,3次都没猜对的话,就直接退出,如果猜对了,打印恭喜信息并退出
count = 3
while count > 0:
age = int(input('请猜:'))
if age == 24:
print('恭喜你猜对啦')
break
else:
count -= 1
print('猜错了,还剩%s次机会!' % count)
12.猜年龄游戏升级版
要求:允许用户最多尝试3次,每尝试3次后,如果还没猜对,就问用户是否还想继续玩,如果回答Y,就继续让其猜3次,以此往复,如
果回答N,就退出程序,如何猜对了,就直接退出。
while 1:
count = 3
while count > 0:
age = int(input('请猜:'))
if age == 24:
print('恭喜你猜对啦')
break
else:
count -= 1
print('猜错了,还剩%s次机会!' % count)
yn = input('是否还想继续玩,回复Y继续,回复N退出:')
if yn.upper() == 'Y':
continue
elif yn.upper() == 'N':
break
13.判断下列逻辑语句的True,False
- 1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
True
not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
False
14.求出下列逻辑语句的值。
8 or 3 and 4 or 2 and 0 or 9 and 7
8
0 or 2 and 3 and 4 or 6 and 0 or 3
4
15.下列结果是什么?
6 or 2 > 1
6
3 or 2 > 1
3
0 or 5 < 4
f
5 < 4 or 3
3
2 > 1 or 6
t
3 and 2 > 1
t
0 and 3 > 1
0
2 > 1 and 3
3
3 > 1 and 0
0
3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2
2