使用Python輸出一個數字金字塔
運行結果:
源代碼:
''' Python輸出數字金字塔 ''' for x in range(1,10): print(' '*(15-x),end='') n=x while n>=1: print(n,sep='',end='') n-=1 n+=2 while n<=x: print(n,sep='',end='') n+=1 print()
使用Python輸出一個數字金字塔
運行結果:
源代碼:
''' Python輸出數字金字塔 ''' for x in range(1,10): print(' '*(15-x),end='') n=x while n>=1: print(n,sep='',end='') n-=1 n+=2 while n<=x: print(n,sep='',end='') n+=1 print()
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。