Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168731
Image: ubuntu2004
def validIsbn(list,length): c=11 for i in range(0,length): c=c-(length+1-i)*list[i] c1=mod(c,11) print 'One obtains c1=',c1, 'hence the ISBN code is: ', for j in range(0,length): if ((mod(j,3)==0)&(j!=0)): print '-', print list[j], print '-',c1
validIsbn([2,1,0,0,5,0,6,9,2],9)
One obtains c1= 7 hence the ISBN code is: 2 1 0 - 0 5 0 - 6 9 2 - 7
def eanCode(list): c=10;a=0;b=0 for i in range(0,6): a=a+list[2*i] print a for i in range(1,7): b=b+list[2*i-1] print b c0=mod(10-(a+3*b),10) print 'The EAN-13 code is: ', for i in range(0,12): if ((i==1)|(i==7)): print '-', print list[i], print c0
eanCode([9,7,8,2,1,0,0,5,0,6,9,2])
27 22 The EAN-13 code is: 9 - 7 8 2 1 0 0 - 5 0 6 9 2 7