#1、使用while循环输入 1 2 3 4 5 6 8 9 10
k = 0
while k < 10:
k += 1
if k == 7:
continue
print(k)
#2.求1-100内所有数的和
k = 0
z = k
while k < 100:
k += 1
z += k
print(z)
sum = 0
for count in range(1,101):
sum += count
print(sum)
#3、输出1-100内的所有奇数或偶数
for i in range(1,101): #奇数
if i % 2 == 1:
print(i)
for i in range(1,101): #偶数
if i % 2 == 0:
print(i)
#4、输出1-100内所有的偶数之和
sum = 0
for i in range(1,101):
if i % 2 == 0:
sum += i
print(sum)
#5.1-2+3-4+5...99的所有数的和
a = 0
b = 0
for i in range(1,101):
if i % 2 == 0:
a += i
else:
b += i
print(b-a)
#6.用户登录(三次机会)
user = 'fan'
paaswd = 'fan'
con = 0
while con < 3:
user1 = input("请输入账号:")
paaswd1 = input("请输入密码:")
if user1 == user and paaswd == paaswd1:
print("登陆成功")
break
else:
print("密码错误")
con += 1
转载于:https://www.cnblogs.com/fan-gx/p/11427436.html