来个特别的
import math
def is_sqr(x):
if math.sqrt(x) % 2 == 0 or 1:
return x
def fn(y):
return y*y
print filter(is_sqr, map(fn,range(1, 11)))
import math
def is_sqr(x):
if math.sqrt(x) % 2 == 0 or 1:
return x
def fn(y):
return y*y
print filter(is_sqr, map(fn,range(1, 11)))
2017-10-14
import math
def add(x, y, f):
return f(x) + f(y)
def f(x1):
return math.sqrt(x1)
print add(25, 9, f)
def add(x, y, f):
return f(x) + f(y)
def f(x1):
return math.sqrt(x1)
print add(25, 9, f)
2017-10-14
http://www.runoob.com/python/python-object.html
看完老师的教程再看看这个网页,里面有很多基本概念的解释,不清楚的可以过一遍概念。
看完老师的教程再看看这个网页,里面有很多基本概念的解释,不清楚的可以过一遍概念。
2017-10-14
import os
from os.path import isdir,isfile
print True
print True
from os.path import isdir,isfile
print True
print True
2017-10-14
def cmp_ignore_case(s1, s2):
if s1[0].lower()<s2[0].lower():
return -1
if s1[0].lower()>s2[0].lower():
return 1
return 0
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
if s1[0].lower()<s2[0].lower():
return -1
if s1[0].lower()>s2[0].lower():
return 1
return 0
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
2017-10-13
import math
def is_sqr(x):
return math.sqrt(x)%1==0
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return math.sqrt(x)%1==0
print filter(is_sqr, range(1, 101))
2017-10-13
import math
def add(x, y, f):
return f(x) + f(y)
print add(25, 9, math.sqrt)
def add(x, y, f):
return f(x) + f(y)
print add(25, 9, math.sqrt)
2017-10-13
def calc_prod(lst):
def a():
s = 1
for i in lst:
s*=i
return s
return a
f = calc_prod([1, 2, 3, 4])
print f()
def a():
s = 1
for i in lst:
s*=i
return s
return a
f = calc_prod([1, 2, 3, 4])
print f()
2017-10-13