Jan 192021
 

用print来搞点好玩的东西,理解一下循环。

打印 5行星星,每行5颗

print

这是一种方法,简单的办法

for i in range (5):
    print (5*'*')

打印三角形

for i in range (5):
    for j in range (0,i+1):
        print ('*',end = '')

    print ('')

print ('')

for i in range (5):
    for j in range (5-i,0,-1 ):
        print ('*',end = '')

    print ('')

打印9*9 乘法口诀

99

看看代码,格式处理上,还是有学问

for i in range(1, 10):
    for j in range(1, i+1):
        print('{}*{}={:<5d}'.format(j, i, i*j), end='')
    print()

  2 Responses to “Python学习笔记8:print”

  1. 陈老师好,我在您之前的帖子下留言评论了,但是为啥一直都是待审核的状态

    • 晚点而已。有空多多交流。我的邮箱:shake.chen@gmail.com. 微信:手机号。13661187180

Leave a Reply to 倪冬冬 Cancel reply

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.