求100以内的所有偶数和
sum = 0
for i in range(1,100):
if i % 2 == 1:
sum += i
print(sum)
求100以内的所有奇数和
sum = 0
for i in range(1,100):
if i % 2 == 0:
sum += i
print(sum)
打印等腰三角形
a = int(input("请输入你要打印等腰三角形的行数:"))
b=1
while b<=a:
i = 1
while i <= a-b:
print(' ', end='')
i += 1
j = 1
while j <= 2*b-1:
print('*',end='')
j += 1
print()
b+=1