Discuss / Python / 我的答案

### 我的答案

Topic source

#### 丰饶之海01

#1 Created at ... [Delete] [Delete and Lock User]

### 第一题

``````def normalize(name):
str=name.lower()
str=name.capitalize()
return str
``````

### 第二题

``````def prod(L):
return reduce(lambda x,y:x*y,L)
``````

### 第三题

``````from functools import reduce
def char2num(s):
return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[s]

def str2float(s):
news=s.split('.')
return reduce(lambda x,y:x*10+y,map(char2num,news[0]))+reduce(lambda x,y:x*10+y,map(char2num,news[1]))/pow(10,len(news[1]))
``````

#### 夏小虫日记

#2 Created at ... [Delete] [Delete and Lock User]

#### 三千背面的小马哥

#3 Created at ... [Delete] [Delete and Lock User]

from functools import reduce def char2num(s): return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[s]

def str2float(s): news=s.split('.') return reduce(lambda x,y:x10+y,map(char2num,news[0]))+reduce(lambda x,y:x10+y,map(char2num,news[1]))/pow(10,len(news[1]))

• 1