打印正方形
按行分开考虑
i=int(input())
print('*'*i)
a ='*'+' '*(i-2)+'*'
for h in range(i-2):
print(a)
print('*'*i)
打印100以内奇数和:
f=0
for i in range(101):
if i&1 == 1:
f=i+f
else:
continue
else:
print(f)
n = int(input())
if n in range(101):
if n in range(60,70):
print('D')
elif n in range(70,80):
print('C')
elif n in range(90,101):
print('A')
elif n in range(80,90):
print('B')
else:
print(E)
else:
print('input num 0~100')
打印5的阶乘:
i = 5
m = 1
for i in range(1,i + 1):
m = i * m
else:
print(m)
验证是不是质数:
效率低:
m = int(input())
for i in range(2,m):
y = m % i
if y == 0:
break
else:
print(‘ok’)
10万以内质数:
效率及其低:
for m in range(1,1000001):
for i in range(2,m):
y = m % i
if y == 0:
break
else:
print(m)