在Python中,你可以使用循环和条件语句来输出10行数据。以下是几种不同的方法:
方法一:使用循环和`end`参数
count = 0for i in range(1, 11):print(i, end=" ")count += 1if count % 10 == 0:print()
方法二:使用`while`循环
num = 0while num < 100:print("*", end=" ")num += 1if (num + 1) % 10 == 0:print()

方法三:使用函数打印杨辉三角形
def print_pascal_triangle(rows):for i in range(rows):print(" " * (rows - i - 1), end="")C = 1for j in range(0, i + 1):print(C, end=" ")C = C * (i - j) // (j + 1)print()print_pascal_triangle(10)
