__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):breakif (a==7):a+=1continuea+=1
__author__ = 'qq593' #!/usr/bin/env python #-*- coding:utf-8 -*- #求1-100所有数的和 a=1 sum0=0 while(a<=100):sum0 = sum0+aa+=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的所有数的和#方法一 # sumj = 0 # sumo = 0 # i = 1 # while(i<100): # if(i%2==0): # sumo+=i # else: # sumj+=i # i+=1 # print(sumj-sumo)#方法二: i=1 he=0 while(i<100):if(i%2==1):he+=ielse:he-=ii+=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!="123"):print("Username or Password wrong,Please input again!(%d/3)"%wtime)wtime+=1else:print("Login Succeed!")break