2.求1-100所有数的和
sum=0 for i in range(101): sum+=i print(sum)3.输出1-100内的所有奇数
li=[] for i in range(1,101): if i%2==1: li.append(i) print(li)4.输出1-100内的所有偶数
li=[] for i in range(1,101): if i%2==0: li.append(i) print(li)6.用户登录,三次机会重试
count=0 while True: uname="myfu" password="123" u,p=input("input your name and password:").split() count+=1 if uname ==u and password ==p: exit("login success") else: if count==3: exit("three times error input,your count is locked") else: print("error username or password ,pls try again,%s time last"%(3-count))
转载于:https://www.cnblogs.com/fumy/p/10248906.html
