首页 > 代码库 > python day1 基本语法作业

python day1 基本语法作业

一、过7

技术分享
1 start =1
2 while start<=10:
3     if start !=7:
4         print(start)
5     start +=1
View Code

二、100以内的和

技术分享
1 sum = 0
2 start = 1
3 while start<=100:
4     sum = sum +start
5     print(start,sum)
6     start+=1
View Code

三、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
View Code

四、登陆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)
View Code

 

python day1 基本语法作业