st="00:00:00"
et="00:00:10"
print abs(int(st.split(':')[0])*3600 + int(st.split(':')[1])*60 + int(st.split(':')[2])-(int(et.split(':')[0])*3600 + int(et.split(':')[1])*60 + int(et.split(':')[2])))
- read more
21.Back to the text string
read morea="xabcbai" n=5 print('YES' if [i for i in range(len(a)-n+1) if a[i:(i+n)] == a[i:(i+n)][::-1]] else 'NO')
20.Information encryption
read morea="cagy" b=33 print(''.join([chr((ord(i)-ord('a')+b)%26+ord('a')) for i in a]))
19.Single song
read morea="abciLOVEjce" UPPER = a.upper() if 'LOVE' in UPPER: print 'LOVE' else: print 'SINGLE'
18.The inverse solution of greatest common divisor and least common multiple
read more# 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 ...
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 ...