(1)利用map函数,把用户输入的不规范的英文字母变成首字母大写
'''
author:ChenRongbo
filename:homework.py
date:7/11/17
desc:hello file
'''
def ul(str): return str.title()
li = [
'LIsten',
'speak',
'rEad',
"Write"]
print map(ul,li)
(2)求积函数
'''
author:ChenRongbo
filename:multiplity.py
date:7/11/17
desc:hello file
'''
def mul(x,y):
return x*y
li = [
1,
2,
3,
4]
print reduce(mul,li)
(3)统计单词数
'''
author:ChenRongbo
filename:wc-word.py
date:7/11/17
desc:hello file
'''
str =
'I like qpy very much'
def wc():
return len(str.split())
print wc()
转载请注明原文地址: https://www.6miu.com/read-73557.html