1
打开JYPTER NOTEBOOK,新建一个PY文档。
2
print(1)
print(12)
print(123)
print(1234)
print(12345)
最简单的方法就是用PRINT,但是数据多的时候就会非常麻烦。
3
rows = int(input("Please input the rows: "))
for i in range(1, rows+1):
for nums in range(1, i+1):
print(nums, end="")
print()
用这个方法想输入多少就显示多少。
4
rows = int(input("Please input the rows: "))
for i in range(1, rows+1):
for nums in range(1, i+1):
print(nums, end="")
print()
测试一下便知,数据多也是可以处理的。
5
rows = int(input("Please input the rows: "))
for i in range(1, rows+1):
for nums in range(1, i+1):
print(nums)
print()
要注意用end=""把换行去掉。
6
rows = int(input("Please input the rows: "))
for i in range(1, rows+1):
for nums in range(1, i+1):
print(nums, end="")
如果最后不打印多一行不会换行。
7
rows = int(input("Please input the rows: "))
for i in range(1, rows+1):
for nums in range(1, i+1):
print(nums)
如果两者都没有,就达不到效果了。
8
rows = int(input("Please input the rows: "))
for i in range(1, rows+1):
for nums in range(1, i+1):
print(i, end="")
print()
如果要重复数字,就要稍微换一下打印的内容了。
END