# x/a=m,y/a=n
# b/x=n,b/y=m
# m*n=b/a
# therefore, x*y==a*b
a=1200
b=120
if a<b:
a,b=b,a
newx=b
newy=a
# x is divisor of a and multiple of b
for x in range(b ...- read more
17.The number of common divisor
read morea=24 b=60 if a<b: smaller=a else: smaller=b count=0 for i in range(1,smaller+1): if a%i==0 and b%i==0: count+=1 print count
16.Print the RMB amount
read more#coding:utf-8 # method 1 a=-20700450 bigFormat={0:u'零',1:u"壹",2:u"贰",3:u'叁',4:u'肆',5:u'伍',6:u'陆',7:u'柒',8:u'捌',9:u'玖'} unit =['',u'拾',u'佰',u'仟',u'万'] rmb="" if a!=abs ...
14.Zen of Python
read moreimport this print this.s
13.Bachelor of sadness
read morea=4 n=0 while a!=0: if a%2!=0: n+=1 a=a//2 print n
12.The parity of the non zero at the end
read moredef count(num,i): if num==0: return 0 if num%i==0: return 1+count(num/i,i) else: return 0 def countodd(list): count2=0 count5=0 for i in range(len(list)): count2 += count(list[i], 2) count5 += count(list[i], 5) if count2>count5: return 0 ...
11.The number of end 0
read moredef count(num,i): if num==0: return 0 if num%i==0: return 1+count(num/i,i) else: return 0 def countzero(list): count2=0 count5=0 for i in range(len(list)): count2 += count(list[i], 2) count5 += count(list[i], 5) if count2>count5: return count5 ...
10.lowest common multiple (lcm)
read morea=10 b=24 def fun(a,b): for i in range(max(a,b),a*b+1): if i%a==0 and i%b==0: n=i break return n print (fun(a,b))
9.greatest common divisor(gcd)
read morea=10 b=24 def fun(a,b): for i in range(1,min(a,b)+1): if a%i==0 and b%i==0: n=i return n print (fun(a,b))
8.the median
read moreL=[0,1,4,2,3,4] L.sort() if len(L)%2==1: print L[len(L)//2] else: print (L[len(L)/2]+L[len(L)/2-1])/2.0