1.使用while循环输入123456 8910
n = 1
while n < 11
if n == 7
pass
else
print(n)
n= n + 1
2.求1-100内所有数的和。
n = 1
s = 0
while n < 101
s= s + n
n= n + 1
print(s)
3.输出1-100内所有的奇数
n = 1
while n < 101
temp = n % 2
if temp == 0
pass
else
print(n)
n= n + 1
4.输出1-100内所有偶数
n = 1
while n < 101
s= n % 2
if s == 0
pass
else
print(n)
n= n + 1
5.求1-2+3-4...99的所有数的总和
n = 1
s = 0
while n < 100
temp = n % 2 求余数
if temp == 0
s = s - n
else
s = s + n
print(s)
n= n + 1 都在条件语句下按一次tab建
6. 用户登录(三次机会重试)
n = 1
while n < 4
mm == "密码‘’
if mm == ‘’密码“
print("可以登录”)
else
n = n + 1
print(结束)
原文地址:https://www.cnblogs.com/yyk520/p/11111723.html
时间: 2024-11-13 04:49:04