day2

11. 求1-2+3-4........+99的和  

i = 0
sum1 = 0
while i < 100:
    i = i + 1
    if i % 2 == 1:
       sum1 = sum1 - i
    else:
       sum1 = sum1 + i
print(sum1)

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

num=3
while num>0:
    user_name=input("please input your ID card: ")
    pwd=input("please input your password: ")
    if user_name=="keyu" and pwd=="2019":
        print("welcome to the login system!")
        break
    else:
        print("your name or password is wrong,please try again")
        num=num-1
        print("your have three times ,now you have only %s times" %num)

 13.简述ASCII、Unicode、utf-8编码
   ASCII: 为美国标准信息码,主要为美国国家服务,可以表示128比特。

   UNICODE:国际通用码,将所有国家的字符进行编码,所有字符占用2个字节,16个比特  空间浪费。

   UTF-8:字母、数字等占用一个字节,8个比特;汉子等占用3个字节。根据信息大小节约空间。

14.简述位和字节。

   1个字节占8个位。 1024bit=1kb   1024kb=1mb 1024mb=1gb  1024gb=1tb

原文地址:https://www.cnblogs.com/andyyangpython/p/10457432.html