s5_day1作业

#1、使用while循环输出1 2 3 4 5 6     8 9 10
# s=0
# while s<10:
#     s+=1
#     if s==7:
#         continue
#     print(s)
# for i in range(1,11):
#     if i==7:
#         continue
#     print(i)
#     i += 1

#2、求1-100的所有数的和
# s=0
# i=0
# while i<100:
#     i+=1
#     s+=i
# print(s)
# s=0
# for i in range(1,101):
#     s+=i
# print(s)

#3、输出 1-100 内的所有奇数
# s=0
# while s<100:
#     s+=1
#     if s%2==1:
#         print(s)
# for i in range(1,101):
#     if i%2==1:
#         print(i)

#4、输出 1-100 内的所有偶数
# s=0
# while s<100:
#     s+=1
#     if s%2==0:
#         print(s)
# for i in range(1,101):
#     if i%2==0:
#         print(i)


#5、求1-2+3-4+5 ... 99的所有数的和
# s=0
# i=1
# while i<100:
#     if i%2==1:
#         s+=i
#     elif i%2==0:
#         s-=i
#     i+=1
# print(s)
# s=0
# for i in range(1,100):
#     if i%2==1:
#         s+=i
#     elif i%2==0:
#         s-=i
# print(s)

#6、用户登陆(三次机会重试)
# count=0
# while count<3:
#     name=input('请输入用户名 ')
#     passwd=input('请输入密码 ')
#     if name=='z' and passwd=='123':
#         print('登录成功')
#         break
#     else:
#         print('用户名密码错误')
#         count+=1


# 改进版
# user='z'
# pwd='123'
# count=0
# while count<3:
#     username=input('请输入用户名 ')
#     if username == user:
#         passwd=input('请输入密码 ')
#         if  passwd==pwd:
#             print('登陆成功')
#             break
#         else:
#             print('密码错误,请重新输入')
#             continue
#     else:
#         count += 1
#         print('用户名错误,请重新输入')
# else:
#     print('您输错了3次,已锁定')

 

posted @ 2017-06-07 18:45  Operater  阅读(223)  评论(0编辑  收藏  举报