Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

201511580440 李坦 #661

Open
Open
@hncsltok

Description

1

(20分)写函数,该函数接收一个参数n。参数n为[1,9]之间的正整数。函数可根据n打印倒三角形到屏幕。形式如图所示,注意除了最后一行以外,每一行的两个数字之间有一个空格。主程序以整数7调用这个函数并打印倒三角形。(如给定n=9,则函数打印三角形如下:)

def f(n):
 assert type(n) == int
 assert n >= 1
 assert n <= 9
 for i in range(n):
 for j in range(i):
 print(' ', end='')
 for j in range(n-i):
 print(n-i, end=' ')
 print()
 
f(7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /