随笔分类 -  python练习案例

摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- l = [] for i in range(3): x = int(raw_input('integer:\n')) l.append(x) l.sort() print l 阅读全文
posted @ 2016-05-26 16:52 七月的尾巴_葵花 阅读(145) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- year = int(raw_input('year:\n')) month = int(raw_input('month:\n')) day = int(raw_input('day:\n')) months = (0,31,59,90,120,151,181,212,243,273,304,334) if... 阅读全文
posted @ 2016-05-26 16:49 七月的尾巴_葵花 阅读(174) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- i = int(raw_input('净利润:')) arr = [1000000,600000,400000,200000,100000,0] rat = [0.01,0.015,0.03,0.05,0.075,0.1] r = 0 for idx in range(0,6): if i>arr[id... 阅读全文
posted @ 2016-05-26 16:48 七月的尾巴_葵花 阅读(147) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- import math for i in range(10000): #转化为整型值 x = int(math.sqrt(i + 100)) y = int(math.sqrt(i + 268)) if(x * x == i + 100) and (y * y == i + 26... 阅读全文
posted @ 2016-05-26 16:48 七月的尾巴_葵花 阅读(126) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- for i in range(1,5): for j in range(1,5): for k in range(1,5): if( i != k ) and (i != j) and (j != k): print i,j,k ... 阅读全文
posted @ 2016-05-26 16:47 七月的尾巴_葵花 阅读(168) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: utf-8 -*- def ntom(x,size,mod): t=[0]*(size) j=0 while x and j1 a和d不能一起去 a+d!=2 a,e,f三人里要去两人 a+e+f==2 b和c都去 或者 都不去 (b+c==0 or b+c==2) c和d两人中只去一个 c+d=... 阅读全文
posted @ 2016-05-23 23:51 七月的尾巴_葵花 阅读(471) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: utf-8 -*- def gcd(x,y): #最大公因子 if x>y:x%=y while x: x,y=y%x,x return y def lcm(x,y): #最小公倍数 return x*y/gcd(x,y) def jhua(x): t=gcd(... 阅读全文
posted @ 2016-05-23 23:50 七月的尾巴_葵花 阅读(294) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: utf-8 -*- from collections import deque from math import log10 def permute(seq, index): seqc = seq[:] seqn = [seqc.pop()] divider = 2 while seqc: inde... 阅读全文
posted @ 2016-05-23 23:49 七月的尾巴_葵花 阅读(385) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: utf-8 -*- from collections import deque def z69(): '''猜牌术(1) 魔术师,最上面一张是黑a,第2次从上到下数2张放在最 底下,然后翻开是黑k,然后再从上到下数3张放 在最底下,是黑q,第k次数k张,依次翻开,得 到黑a~1;问原始的牌序''' ss=13 ... 阅读全文
posted @ 2016-05-23 23:47 七月的尾巴_葵花 阅读(239) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: utf-8 -*- from math import sqrt import random def daoxu(n): d=n s=0 while d!=0: d,f=divmod(d,10) s=f+s*10 return s def z85(): #任意取一个十进制数如12... 阅读全文
posted @ 2016-05-23 23:45 七月的尾巴_葵花 阅读(293) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python # -*- coding: utf-8 -*- def z94(): #斐波那契数列 def filie(x): a,b,t=1,1,0 if x==1 or x==2:return 1 while t!=x-2: a,b,t=b,a+b,t+1 retur... 阅读全文
posted @ 2016-05-23 23:44 七月的尾巴_葵花 阅读(251) 评论(0) 推荐(0) 编辑
摘要:from math import sqrt from datetime import date def k1(): #某人是1999年9月29日生日 #问到2006年9月29日他活了多少天 a=date(1999,9,29) b=date(2006,9,29) c=str(b-a).split(" ") print int(c[0]) ... 阅读全文
posted @ 2016-05-23 23:32 七月的尾巴_葵花 阅读(422) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/env python # -*- coding: utf-8 -*- """ @desc: search in mail box """ import unittest import os import sys from selenium import webdriver from selenium.webdriver.common.keys import K... 阅读全文
posted @ 2016-05-20 18:05 七月的尾巴_葵花 阅读(301) 评论(0) 推荐(0) 编辑