- 博客(27)
- 收藏
- 关注
原创 翻译器
import urllib.request import urllib.parse import json content=input("请输入要翻译的内容") url='http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=null' dat
2016-07-04 21:37:38
451
原创 保存图片
import urllib.request response=urllib.request.urlopen("http://placekitten.com/g/500/600") cat_img=response.read() with open('cat_500_600.jpg','wb') as f: f.write(cat_img)
2016-07-04 21:36:58
538
原创 python实现欧拉计划29题
注意set的使用 =================== print (len(set(a**b for a in range(2, 101) for b in range(2, 101))))
2016-05-27 12:10:37
385
原创 pyhton实现欧拉计划28题
sum=1 x=1 for i in range(1,501): for j in range(0,4): x=x+2*i sum=sum+x print (sum) =========================== 思路 1 2,3,4,5,6,7,8,9、 10,11,12,13,14,15,16,17,18,19,20,21
2016-05-27 11:53:52
304
原创 Python实现欧拉计划27题
import math from time import clock time1=clock() def IsPrime(x): if x return False for i in range(2,int(math.sqrt(x))+1): if x%i==0: return
2016-05-24 20:10:55
335
原创 python 实现欧拉计划26题
def cycle_length(n): i = 1 if n % 2 == 0: return cycle_length(n / 2) if n % 5 == 0: return cycle_length(n / 5) while True: if (10**i - 1) % n == 0: return i else:
2016-05-17 16:13:18
432
原创 python实现欧拉计划25题
def f(n): if n==1 or n==2: return 1 else: a=D[n-1]+D[n-2] D[n]=a return a n=1 D={1:1,2:1} while len(str(f(n))) n=n+1 print f(n) print n ===
2016-05-17 13:37:30
359
原创 python实现欧拉计划24题
逆康拓展开式 import math L=[0,1,2,3,4,5,6,7,8,9] M=[] m=999999 for i in range(9,-1,-1): x=(m/(math.factorial(i))) print x y=(m%(math.factorial(i))) m=y M.append(L[x]) L.po
2016-05-16 16:55:16
321
原创 Python实现欧拉计划23题
def d(i): k=0 #判断一个数(小于28123)是否写成两个过剩数的和,不能的话返回为真 for m in range(0,len(M)): for n in range(0,len(M)): #M为小于28123的所有的过剩数 if i==M[m]+M[n]
2016-05-13 19:41:32
562
原创 欧拉计划23
def d(i): k=0 #判断一个数(小于28123)是否写成两个过剩数的和,不能的话返回为真 for m in range(0,len(M)): for n in range(0,len(M)): #M为小于28123的所有的过剩数 if i==M[m]+M[n]
2016-05-13 19:40:03
525
原创 Python实现欧拉计划22题
def f(n): value={'A':1,'B':2,'C':3,'D':4,'E':5,'F':6,'G':7,'H':8,'I':9,'J':10,'K':11,'L':12,'M':13,'N':14,'O':15,'P':16,'Q':17,'R':18,'S':19,'T':20,'U':21,'V':22,'W':23,'X':24,'Y':25,'Z':26,}
2016-05-10 14:52:15
327
原创 Python实现欧拉计划21题
def d(n): result=[a for a in range(1,n) if n%a==0] y=sum(result) return y L=[] for i in range(2,10001): m=d(i) if d(m)==i and m!=i: L.append(i) i=i+1 print su
2016-05-08 15:06:47
325
原创 Python实现欧拉计划20题
n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digi
2016-05-03 15:28:02
757
原创 Python实现欧拉计划19题
You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday.Thirty days has September, April, June and November. All the rest have thirty
2016-05-03 14:48:50
472
原创 yield
http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/00138681965108490cb4c13182e472f8d87830f13be6e88000
2016-05-03 13:05:41
238
原创 python中else可以和什么搭配
1 if-else 2 else-if(elif) 3 while-else & for-else 工作顺序:else在循环完成后执行,只要循环正常结束,而不是通过break,eles就会执行。break语句会跳过else代码块 4 try-else 在try范围内没有检测到异常的时候,执行else
2016-05-03 13:01:00
1456
原创 python实现欧拉计划18题
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find th
2016-04-30 12:14:32
453
原创 Python实现欧拉计划17题
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive we
2016-04-29 14:16:26
855
原创 Python实现欧拉计划16题
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 21000? --------------------------------------------------------------------------- a=str
2016-04-28 19:18:25
355
原创 python实现欧拉计划15题
Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 2
2016-04-28 18:36:59
347
原创 python实现欧拉计划第十四题
The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequen
2016-04-27 12:13:58
522
原创 python实现欧拉计划第十三题
Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 7432498
2016-04-27 11:27:56
856
原创 python实现欧拉计划第十二题
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 2
2016-04-27 10:50:36
543
转载 python实现欧拉计划第十一题
In the 20×20 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56
2016-04-27 09:05:14
757
原创 Python实现KNN算法
from numpy import * import operator def creatDataset(): group = array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]]) lables = ['A','A','B','B'] return group,lables
2016-04-26 20:23:31
421
原创 Python实现欧拉计划第十题
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. ---------------------------------------------------------------------------------- fr
2016-04-26 12:17:56
386
原创 Python实现欧拉计划第九题
A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b +
2016-04-26 10:48:56
447
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅