乘法表: for i in range(1, 10): for j in range(1, i+1): print('{}*{}={}\t'.format(j, i, j*i), end='') print() 判断素数: from numpy import append num = [] i = 2 for i in range(1, 300): for j in range(2, i): if(i % j == 0): break else: num.append(i) print(num) 输出等边三角形: for i in range(0, 10): for j in range(0, 10-i): print(" ", end="") for k in range(0, i): print("* ", end="") print() 验证登录: count = 0 while count < 3: user_name = input("user:") user_password = input("password:") if user_name == "admin" and user_password == "123456": print("Hello admin ") break else: print("Worring") count += 1