下午为了巩固学了两天的python花了两小时写了一段脚本(非常脑残...)没有注释,将就看看吧...(适用于python2.7),源码如下:
print '*****welcome to the first python computer program of scy ******'pd = 1while pd>0: def range1(x,y=1): sum = 0 if y == 1: a = range(0,x,2) for numbers in a: sum = sum + numbers return sum else: while x>0: sum = sum + x x = x - 2 return sum b = raw_input('enter model' ) b = int (b) c = raw_input('enter number-max' ) c = int (c) d = c % 2 if d == 0: c = c - 1 finish = range1(c,b) print finish pd2=raw_input('would you like to try it again?(y/n)' ) if pd2 =='n': pd = pd - 2print 'welcome come back'
(贴吧没有换行符也是醉了...
![](http://tb2.bdstatic.com/tb/editor/images/face/i_f30.png?t=20140803)
)