During the Christmas period, I looked at the python for loop. Just practice, on a whim, wrote a small program of the Christmas tree. For Gentlemen a happy!
The following code is attached:
#coding: Utf-8import sysdef christmas (h): print ' \033[1;36;40m\t Welcome to!\n is making your own Christmas tree, please wait! \033[0m ' print ' \033[1;32;40m ' # print ' t ', for i in range (1,h+1): print ' t ', for j In range (0,h-i): print ' ', i=2* I-1 for j in range (0,i): print ' * ', print for i in range (1,h+1): print ' t ', for j in range (1,h): print ' ', print ' * ' print ' \033[1;31; 40m merry christmas!\033[0m ' Christmas (int (sys.argv[1]))
Below is the result of the operation:
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/8C/0C/wKioL1hgykiCAVMJAAAEWFix85Y314.png-wh_500x0-wm_3 -wmp_4-s_612390252.png "title=" Result.png "alt=" Wkiol1hgykicavmjaaaewfix85y314.png-wh_50 "/>
This article is from the "Little Flash" blog, please be sure to keep this source http://jack88.blog.51cto.com/12348665/1886205
The Christmas tree of the Little Python game