張浩3

weixin_43880990發表於2018-11-30

1、等腰三角形

#!/usr/bin/python
#coding=utf-8

import sys,types

if len(sys.argv) == 2:
LENTH = sys.argv[1];
else:
print ‘This tool must have one parameter’;
print ‘e.g.’;
print ‘./1.py 5’;
sys.exit(1);

if LENTH.isdigit():
j = int(LENTH);
if j >= 50:
print ‘ERR: PLS input the number less than 50’;
sys.exit(1);
print “U imupt number: %d” %(j);
else:
print ‘ERR: PLS input number and the number must lager than 0’;
sys.exit(1);

for j in range (1,j+1):
print '* ’ * j

2、等腰三角形2
k = 0;
for i in range (1,j+1):
k = k + 1;
l = j - k;
m = i+i-1;
print (’ ’ * l + '* ’ * m );

3、回形

相關文章