返回列表 發帖

巢狀迴圈 (一) - 九九乘法表

顯示如下之九九乘法表

  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print("%d*%d=%-2d"%(i,j,i*j),end="  ")
  4.     print()
複製代碼
  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print("{}*{}={}".format(i,j,i*j),end="\t")
  4.     print()
複製代碼
  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print(f"{i}*{j}={i*j}",end="\t")
  4.     print()
複製代碼

for i in range(1,10):
    for j in range(1,10):
        print("%d*%d=%-2d"%(i,j,i*j),end=" ")
    print()

TOP

  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print(f"{i}*{j}={i*j}",end="\t")
  4.         print()
複製代碼

TOP

  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print(f"{i}*{j}={i*j}",end="\t")
  4.     print()
複製代碼

TOP

7

TOP

  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print(f'{i}x{j}={i*j}',end=' ')
  4.     print()
複製代碼

TOP

for i in range(1,10):
    for j in range(1,10):
        print(f"{i}*{j}={i*j}",end"\t")

TOP

  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print(f"{i}*{j}={i*j}",end="\t")
  4.     print()
複製代碼

TOP

  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print(f"{i}*{j}={i*j}",end="\t")
  4.     print()
複製代碼

TOP

  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print(f"{i}*{j}={i*j}",end="\t")
  4.     print()
複製代碼

TOP

  1. for i in range(1,10):
  2.     for j in range(1,10):
  3.         print(f"{i}*{j}={i*j}",end="\t")
  4.     print()   
複製代碼

TOP

  1. for a in range(1,10):
  2.     for b in range(1,10):
  3.         print(f"{a}*{b}={a*b}",end="\t")
  4.     print()
複製代碼

TOP

返回列表