python作业(1)

# 使用while循环输出1234568910
 count=1
 while count<11:
     if count==7:
         pass
     else:
         print(count)
     count=count+1


# 求1-100之间所有数的和
 n=1
 he=0
 while n<=100:
     he=he+n
     n=n+1
 print(he)



# 输出1-100内所有的奇数
 a=1
 while a<=100:
     if a%2!=0:
         print(a)
     a=a+1





# 输出1-100内所有的偶数
 b=1
 while b<=100:
     if b%2==0:
         print(b)
     b=b+1




# 求1-2+3-4+5-6+7.....99所有数的和
c=1
he=0
while c<=99:
    if c%2==0:
        he=he-c
    else:
        he=he+c
    c=c+1
print(he)

 

# 用户登录三次重试机会
s1=0
while s1<3:
    user=input('请输入账号')
    pwd=input('请输入密码')
    if user='root' and pwd='root':
        print('恭喜登陆成功')
        break
    else:
        print('账号或密码错误')
    s1=s1+1

 

注意:

input('....')一直等待输入如果不输入就不会执行

 

pass 闪过 什么也不输出

posted @ 2018-08-17 11:56  火虎true(false)  阅读(127)  评论(0编辑  收藏  举报