__author__ = 'qq593'
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#使用while循环输入1 2 3 4 5 6 8 9 10
a=1
while True:
print(a)
if(a==10):
break
if (a==7):
a+=1
continue
a+=1
__author__ = 'qq593'
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#求1-100所有数的和
a=1
sum0=0
while(a<=100):
sum0 = sum0+a
a+=1
print(sum0)
__author__ = 'qq593'
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#输出1-100内所有奇数
a=1
while(a<101):
if(a%2!=0):
print(a)
a+=1
__author__ = 'qq593'
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#输出1-100内所有偶数
a=1
while(a<101):
if(a%2==0):
print(a)
a+=1
__author__ = 'qq593'
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#求1-2+3-4+5….99的所有数的和
#方法一
#方法二:
i=1
he=0
while(i<100):
if(i%2==1):
he+=i
else:
he-=i
i+=1
print(he)
__author__ = 'qq593'
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#用户登录(三次机会重试)
wtime=1
while(wtime<=3):
user = input("Username:")
pwd = input("Password:")
if (user!="xb" or pwd!=""):
print("Username or Password wrong,Please input again!(%d/3)"%wtime)
wtime+=1
else:
print("Login Succeed!")
break
手机扫一扫
移动阅读更方便
你可能感兴趣的文章