Discuss / Python / 交作业

交作业

Topic source

ForkPanda

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

第一题

def normalize(name):
    return name.lower().capitalize()

第二题

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

第三题

def str2float(s):
    return reduce(lambda x, y: x * 10 + y, map(int, s.replace(".", ""))) / (10 ** s.find("."))

ForkPanda

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

第三题写错了- -WTF

def str2float(s):
    return reduce(lambda x, y: x * 10 + y, map(int, s.replace(".", ""))) / (10 ** (len(s) - s.find(".") - 1))

xixi__无敌

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

第一题我尝试了下直接使用name.capitalize()就已经可以做到了

翁岚敏

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

靠这样看来我也写反了


  • 1

Reply