# 0 - 100的和
i = 0
sum = 0

while i <= 100:
    sum += i
    i += 1

print("The sum of 1 ~ 100 is %d" % sum)

# 0 - 100所有偶数的和

i = 0
sum_even = 0
sum_odd = 0

while i <= 100:
    if i % 2 == 0:
        sum_even += i
    else:
        sum_odd += i
    i += 1

print("The sum of 1 ~ 100 even is %d" % sum_even)
print("The sum of 1 ~ 100 odd is %d" % sum_odd)

# 使用while嵌套打印
# *
# **
# ***
# ****
# *****
line = 1
while line <= 5: # <=处理行
    col = 1
    while col <= line: # <=处理列
        print("*", end="")
        col += 1
    print("")
    line +=1

# 9 x 9 乘法表

x = 1
y = 1

while x <= 9:
    y = 1
    while y <= x:
        print("%d * %d = %d\t" % (y, x, x*y), end="")
        y += 1
    print("")
    x += 1
