热线电话:13121318867

登录
2019-02-21 阅读量: 722
如何用python输出阶梯模型

# Python 3.x code to demonstrate star pattern

# Function to demonstrate printing pattern of numbers

def numpat(n):

# initialising starting number

num = 1

# outer loop to handle number of rows

for i in range(0, n):

# re assigning num

num = 1

# inner loop to handle number of columns

# values changing acc. to outer loop

for j in range(0, i+1):

# printing number

print(num, end=" ")

# incrementing number at each column

num = num + 1

# ending line after each row

print("\r")

# Driver code

n = 5

numpat(n)

0.0000
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子