python day1 基本语法作业
一、过7
1 start =1 2 while start<=10: 3 if start !=7: 4 print(start) 5 start +=1
二、100以内的和
1 sum = 0 2 start = 1 3 while start<=100: 4 sum = sum +start 5 print(start,sum) 6 start+=1
三、100内奇数偶数差的和
1 i = 1 2 sum = 0 3 while i<=100: 4 if i%2 ==1: 5 sum1 = sum + i 6 if i%2 ==0: 7 sum =sum1 -i 8 print(sum) 9 i+=1
四、登陆3次限制
1 time = 0 2 while time<3: 3 name = input("name:") 4 passwd = input("pwd:") 5 print(name,passwd) 6 time+=1 7 print('end')