#1.判断下列逻辑语句的True,False.
‘’’
1:真的
2:假的
‘’’
#2.求出下列逻辑语句的值。
1),8 or 3 and 4 or 2 and 0 or 9 and 7
2),0 or 2 and 3 and 4 or 6 and 0 or 3
‘’’
1:8
2:4
‘’’
#3.下列结果是什么?
1)、6 or 2 > 1
2)、3 or 2 > 1
3)、0 or 5 < 4
4)、5 < 4 or 3
5)、2 > 1 or 6
6)、3 and 2 > 1
7)、0 and 3 > 1
8)、2 > 1 and 3
9)、3 > 1 and 0
10)、3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2
‘’’
1:真的
2:真的
3:假的
4:假的
5:真的
6:真的
7:假的
8:假的
9:真的
10:真的
‘’’
#4.while循环语句基本结构?
‘’’
1:while空格条件冒号
缩进循环体(代码块)
‘’’
#5.利用while语句写出猜大小的游戏:
#设定一个理想数字比如:66,让用户输入数字,如果比66大,则显示猜测的结果大了;如果比66小,则显示猜测的结果小了;只有等于66,显示猜测结果正确,然后退出循环。
‘’’
a = 66
while Tyue:
b = input(“请输入数字”)
if int(b) > a:
print(“结果大了”)
else:
print(“结果小了”)
if int(b) ==a:
print(“结果正确”)
break
‘’’
#6.在5题的基础上进行升级:
#给用户三次猜测机会,如果三次之内猜测对了,则显示猜测正确,退出循环,如果三次之内没有猜测正确,则自动退出循环,并显示‘太笨了你…’
‘’’
a = 66
count = 0
while count < 3:
b = input(“请输入数字”)
if int(b) > a:
print(“结果大了”)
else:
print(“结果小了”)
if int(b) == a:
print(“结果正确”)
break
count = count + 1
else:
print(“你太笨了”)
‘’’
#7.使用while循环输出 1 2 3 4 5 6 8 9 10
‘’’
count = 1
while count < 10:
if count == 7:
count = count + 1
continue
print(count)
count = count + 1
‘’’
#8.求1-100的所有数的和(两种方法)
‘’’
count = 1
b = 0
while count < 101:
b = b + count
count = count + 1
print(b)
‘’’
#9.输出 1-100 内的所有奇数(两种方法)
‘’’
count = 1
while count < 101:
if count % 2 == 1:
print(count)
count = count + 1
‘’’
‘’’
count = 1
while count < 101:
count = count + 2
print(count)
‘’’
#10.输出 1-100 内的所有偶数(两种方法)
‘’’
count = 1
while count < 101:
if count % 2 == 0 :
print(count)
count = count + 1
‘’’
‘’’
count = 0
while count < 101:
count = count + 2
print(count)
‘’’
#11.求1-2+3-4+5 … 99的所有数的和
‘’’
count = 1
sum = 0
while count < 100:
if count%2 == 1:
sum+=count
elif count%2 == 0:
sum - = count
count + = 1
print(sum)
‘’’
‘’’
count = 1
sum = 0
while count < 100:
if count%2 == 1:
sum+=count
elif count%2 == 0:
sum-= count
count+= 1
print(sum)
‘’’
#12.⽤户登陆(三次输错机会)且每次输错误时显示剩余错误次数(提示:使⽤字符串格式化)
‘’’
count =1
while cont<4:
a=input(“请输入账户”)
b=input(“请输入密码”)
if a=="123"and b==“abc”:
print(“登录成功”)
break
else:
print(“还剩次数为”)
print(3-count)
count+=1
‘’’
#13.简述ASCII、Unicode、utf-8编码关系?
‘’’
Ascii不支持中文,Unicode万国码分16位(2字节)英文 中文32位(4字节) UTF-8英文使用最少8位(1字节)
欧洲:16位 (2字节) 亚洲:24位(3字节)
‘’’
#14.简述位和字节的关系?
‘’’
8(bit) == 1(byte)字节
1024(byte) = 1kb(千字节)
‘’’
#15.“⽼男孩”使⽤UTF-8编码占⽤⼏个字节?使⽤GBK编码占⼏个字节?
‘’’
UTF-8占24位,GBK中文占2字节,英文占1字节
‘’’