标签:python小小尝试
# -*- coding:utf-8 -*- #输出一个金字塔 ‘‘‘ num = 10 for hang in range(num):print ‘ ‘ * (num - hang) + ‘*‘ * (hang * 2 - 1) ‘‘‘ #输出一个镂空金字塔 ‘‘‘ num = 10 for hang in range(1,num): if(hang == 1 or hang == (num - 1)):print ‘ ‘ * (num - hang) + ‘*‘ * (hang * 2 - 1) else:print ‘ ‘ * (num - hang) + ‘*‘ + ‘ ‘ * (hang * 2 - 3) + ‘*‘ ‘‘‘ #输出一个菱形 ‘‘‘ num = 10 for hang in range(1,num - 1):print ‘ ‘ * (num - hang) + ‘*‘ * (hang * 2 - 1) for hang in range(1,num):print ‘ ‘ * (hang) + ‘*‘ * ((num - hang) * 2 - 1) ‘‘‘ #镂空菱形 ‘‘‘ num = 10 for hang in range(1,num - 1): if(hang == 1):print ‘ ‘ * (num - hang) + ‘*‘ else:print ‘ ‘ * (num - hang) + ‘*‘ + ‘ ‘ * (hang * 2 - 3) + ‘*‘ for hang in range(1,num): if(hang == (num - 1)):print ‘ ‘ * hang + ‘*‘ else:print ‘ ‘ * (hang) + ‘*‘ + ‘ ‘* ((num - hang) * 2 - 3) + ‘*‘ ‘‘‘
本文出自 “anka” 博客,请务必保留此出处http://anka0501.blog.51cto.com/10129669/1677332
标签:python小小尝试
原文地址:http://anka0501.blog.51cto.com/10129669/1677332