Python Exercise 1

Source: Internet
Author: User

 fromMathImportsqrt fromDatetimeImportDatedefK1 ():#someone is September 29, 1999 birthday    #asked how many days he lived on September 29, 2006.A=date (1999,9,29) b=date (2006,9,29) C=str (b-a). Split (" ")    PrintInt (c[0])returnInt (c[0])defK2 ():#four digits the first two bits are the same, the last two are the same, and is a natural number squared, ask him how muchT=range (1,10)     forIinchT: forJincht:m=i*1100+j*11N=Int (sqrt (m))ifM==n*n andi!=J:PrintmdefK3 ():#Bank monthly 0.63%, one intends to take 1000 at the end of each year for the next five years, just to finish, asking how much the first year should be savedTl=0 forIinchRange (5): TL= (tl+1000.0)/(1+0.0063*12)    PrintTLdefK4 ():" "The interest rate for the whole deposit and saving is 1,2,3,5,8 year 0.63%,0.66%,0.69%,0.75%,0.84% deposit 20 Money ask how to save the most" "L1=[8,5,3,2,1] L2=[0.0084,0.0075,0.0069,0.0066,0.0063] NN=20Maxx=0 L3=map (Lambdax,y:1+12*x*y, L1,l2) forIinchRange (nn/l1[0]+1):         forJinchRange (nn/l1[1]+1):             forAinchRange (nn/l1[2]+1):                 forBinchRange (nn/l1[3]+1): T=nn-i*l1[0]-j*l1[1]-a*l1[2]-b*l1[3]                    ift>=0:kk=[i,j,a,b,t] kt=reduce (LambdaX, Y:x*y, map (Lambdax,y:x**Y,l3,kk)) ifKt>Maxx:maxx=kt KKK=KKPrintkkk,2000*MaxxdefK5 ():" "Five people fishing, a first will be divided into 5 parts of the fish, the surplus of a throw away, take one of their own, bcde the same way, ask fish at least how many strips" "N=1nn=5Flag=0 whileflag==0:n+=5s=N forIinchRange (5): S,y=divmod (s-1,5)            ify==0:s*=4Flag=1Else: Flag=0 Break    PrintNdefK6 ():" "Sell the fish, sold 1/2 plus 1/2 for the first time, sold 1/3 plus 1/3 for the 2nd time, and sold 1/4 plus 1/4 4th times for 1/5 plus 1/5 for the remaining 11 strips. How many lines are there in the first question?" "N=23nn=5Flag=0 whileflag==0:n+=2SS=N forIinchRange (1,5): S,y=divmod (ss+1, (i+1))            ify==0:ss-=s Flag=1Else: Flag=0 Break    PrintNdefK7 ():#21 Baskets of fish, 7 baskets full, 7 baskets and half, 7 baskets empty, in the case of not pouring out the fish, how to flat divided into 3 partsk=[]     forIinchRange (1,4): K+=[[i,7-i*2, I]] #Print K     forIinchK: forJinchK: forMinchK:l3=map (Lambdax,y,z:x+y+Z, i,j,m)ifI<=j<=m andL3[0]==7 andL3[1]==7:                    Print[I,j,m]if __name__=='__main__': S=""     forIinchRange (11,18): S+='Z'+str (i) +'() \ n'    exec(s)

Python Exercise 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.