¡¾Python¡¿ÓÃPythonÀ´ÊµÏÖ´Õ24µÄ³ÌÐò
´Õ24ÊǾµäµÄÒæÖÇÓÎÏ·£¬¶àÍæ¿ÉÒÔʹÄÔ½îÁé»îÒ»µã£¬µ«Êǵ±Óöµ½ÎÞ½âµÄʱºò£¬¾Í»áºÜÉËÄԽΪ´Ë£¬Ð´¸ö³ÌÐòÀ´´úΪ¼ÆËã¡£
ÔËÐнá¹û£¬È¥³ýÁËÖØ¸´µÄһЩ±í´ïʽ£º
entry: 1
entry: 4
entry: 5
entry: 6
(4/(1-(5/6))) = 24
(6/((5/4)-1)) = 24
Press any key to exit...
entry: 3
entry: 3
entry: 8
entry: 8
(8/(3-(8/3))) = 24
Press any key to exit...
¸½Ô´Â룺
NUMBER=4
TOTAL=24
class data:
pass
def Simplify(a, b):
desta=a;destb=b
if b==0 or b==1:return desta, destb
if a==0 or a==1:return desta, destb
if a>b:n=b
else:n=a
for i in range(2,n+1):
while n != i:
if a%i==0 and b%i==0:
a=a/i;b=b/i;n=n/i
else:break
if a%n==0 and b%n==0:
a=a/n;b=b/n
desta=a;destb=b
return desta, destb
def MergeList(L1, L2):
LSum=[]
if L1==[]:
for i in range(len(L2)):
LSum.append(L2[i])
return LSum
if L2==[]:
for i in range(len(L1)):
LSum.append(L1[i])
return LSum
#fenmu:denominator fenzi:numerator
#L:0 fenzi 1 fenmu 2 format
for i in range(len(L1)):
for j in range(len(L2)):
#+
tempa=L1[i].a * L2[j].b + L1[i].b * L2[j].a
tempb=L1[i].b * L2[j].b
tempobj=data()
tempobj.a, tempobj.b = Simplify(tempa, tempb)
if tempobj.a == 0:tempobj.b=1
tempobj.c = "(%s+%s)" % (L1[i].c, L2[j].c)
LSum.append(tempobj)
#-
tempa=abs(L1[i].a * L2[j].b - L1[i].b * L2[j].a)
tempb=L1[i].b * L2[j].b
tempobj=data()
tempobj.a, tempobj.b = Simplify(tempa, tempb)
if tempobj.a == 0:tempobj.b=1
if L1[i].a * L2[j].b > L1[i].b * L2[j].a:
tempobj.c = "(%s-%s)" % (L1[i].c, L2[j].c)
else:tempobj.c = "(%s-%s)" % (L2[j].c, L1[i].c)
LSum.append(tempobj)
#*
tempa
Ïà¹ØÎĵµ£º
×ªÔØ×Ô£ºhttp://hi.baidu.com/myitlyj/blog/item/25586bd7088ba3dba044df6b.html
ÔÚ³ÌÐòÖÐʹÓÃÅäÖÃÎļþÀ´Áé»îµÄÅäÖÃһЩ²ÎÊýÊÇÒ»¼þºÜ³£¼ûµÄÊÂÇ飬ÅäÖÃÎļþµÄ½âÎö²¢²»¸´ÔÓ£¬ÔÚpythonÀï¸üÊÇÈç´Ë£¬ÔÚ¹Ù·½·¢²¼µÄ¿âÖоͰüº¬ÓÐ×öÕâ¼þÊÂÇéµÄ¿â£¬ÄǾÍÊÇConfigParser£¬ÕâÀï¼òµ¥µÄ×öһЩ½éÉÜ¡£
ConfigParser½âÎöµÄÅäÖÃÎļþµÄ¸ñÊ ......
¹¤¾ßÀ¸->¸ß¼¶->ÅäÖÃ->±à¼Æ÷ÏÔʾ->Óï·¨¼ÓÁÁ->´ò¿ª
ÔÚ´ò¿ªµÄÎļþÖнáβ¼ÓÉÏÏÂÃæÎÄ×Ö£¬²¢±£´æ¡£
/L10"Python" Line Comment = # Block Comment One = """ Block Comment Off = """ Escape Char = \ File Extensions = PY PYW
/Indent Strings = ":"
/Function String 1 = "%[ ,^t]++def[ ]+^([a-zA-Z0-9_] ......
import sys, pygame, time
size = width, height = 700,700
fontColor = (0,0,255)
class walk:
'''This is a game about war.
Just like war 3.'''
def __init__(self):
'''Init the screen.
Get param and init the screen'''
#print ('this is init funnction') ......
¹«Ë¾µÄ´úÀí¿ÉÒÔÖ±½Ó´©Ç½£¬×ÔÓÉ·ÃÎÊTwitter¡¢FacebookµÈÍøÕ¾£¬ÕâÁ½ÌìÑо¿ÁËÒ»ÏÂTwitterÌṩµÄAPI£¬ÓÃpythonдÁËÒ»¸ötwitter client£¬Ö»ÊµÏÖÁË»ù±¾¹¦ÄÜ£¬²é¿´×Ô¼ºµÄtwitterÏûÏ¢£¬Ò²¿ÉÒÔ²»ÑéÖ¤£¬²é¿´publicµÄtwitterÏûÏ¢¡£ÆäËû¹¦ÄÜʵÏÖÀàËÆ¡£Ö÷Òªº¯ÊýÈçÏ£º
def fetch_with_proxy(proxy, username, password, url):
&n ......
#!/usr/bin/python
#coding=utf-8
import Image,ImageDraw,ImageFont,os,string,random,ImageFilter
def initChars():
"""
ÔÊÐíµÄ×Ö·û¼¯ºÏ£¬³õʼ¼¯ºÏΪÊý×Ö¡¢´óСд×Öĸ
usage: initChars()
param: None
return: list
·µ»ØÔÊÐíµÄ×Ö·û¼¯ºÍ
for: picCheckerÀà³õʼ×Ö·û¼¯ºÏ
todo: ......