python的for循环、while循环

1、for循环使用之乘法表

for i in range(1,10):
    for j in range(1,i+1):
        print('%s * %s = %s  '%(j,i,i*j),end='')
    print(end='\n')

2、while 循环之20以内奇数输出

count = 0
while count <= 20:
    if count %2 != 0:
        print(count)
    count = count + 1

猜你喜欢

转载自www.cnblogs.com/blueteer/p/9953158.html