“”" 答:1是True. 2是False “”"
“”“答:1题是 8 2题是 4 “””
“”“答:1题是True 2题是True 3题是False 4题是True 5题是True 6题是True 7题是False 8题是False 9题是True 10题是True “””
“”“答: while 条件 循环体(“代码块”) print() print() “””
“”" a = 66 while True: b = input(“请输入数字:”) if int(b) > a: print(“结果大了”) else: print(“结果小了”) if int(b) == a: print(“正确”) break “”"
“”" a = 66 c = 0 while c < 3: b = input(“请输入数字:”) if int(b) > a: print(“结果大了”) else: print(“结果小了”) if int© == a: print(“正确”) break c = c + 1 else: print(“你太笨了”) “”"
“”" count = 1 while count < 11: if count == 7: count = count + 1 continue print(count) count = count + 1 “”"
“”" count = 1 b = 0 while count < 101: b = b + count count = count + 1 print(b) “”" “”" b = 0 a = 1 while a < 101: b = b + a a = a + 1 print(b) “”"
“”" count = 1 while count < 101: if count % 2 == 1: print(count) count = count + 1 “”" “”" count = 1 while count < 101: count = count + 2 print(count) “”"
“”" count = 1 while count < 101: if count % 2 ==0: print(count) count = count + 1 “”" “”" count = 1 while count < 101: if count % 2 == 0: print(count) count = count + 1 “”"
“”“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 count<4: a=input(“请输入账户”) b=input(“请输入密码”) if a == “123” and b == “abc”: print(“登陆成功”) break else: print(“还剩次数为”) print(3-count) count+=1 “”"
“”" Ascii不支持中文,Unicode万国码分16位(2字节)英文 中文32位(4字节) UTF-8英文使用最少8位(1字节) 欧洲:16位 (2字节) 亚洲:24位(3字节) “”"
“”" 8(bit) == 1(byte)字节 1024(byte) = 1kb(千字节) “”"
“”" UTF-8占24位,GBK中文占2字节,英文占1字节 “”"