赞
踩
def solution(to,lst):
dolSym, eurSym, power = ('', '€', -1) if to=='EUR' else ('$','', 1)
return [f"{ dolSym }{ v*1.1363636**power :,.2f}{ eurSym }" for v in lst]
def solution(to_cur, values):
rate = 1.1363636
style = "{:,.2f}"
if to_cur == "EUR":
rate = 1 / rate
style += "€"
else: # "USD"
style = "$" + style
return [style.format(v * rate) for v in values]
def solution(to_cur,value):
#multiply number by appropriate conversion rate, and round using the ",.2f" format (rounds/pads to last 2 decimals and uses commas)
return [f"${i*1.1363636:,.2f}" if to_cur == "USD" else f"{i/1.1363636:,.2f}€" for i in value]
def solution(to_cur,value):
r = []
for number in value:
if to_cur == "USD":
r.append("${:,.2F}".format(number * 1.1363636))
else:
r.append("{:,.2F}€".format(number / 1.1363636))
return r
def solution(to_cur,value):
if to_cur is 'USD':
return [f'${i*1.1363636:,.2f}' for i in value]
if to_cur is 'EUR':
return [f'{i/1.1363636:,.2f}€' for i in value]
conv = {
'EUR': lambda v: '{:,.2f}€'.format(round(v/1.1363636,2)),
'USD': lambda v: '${:,.2f}'.format(round(v*1.1363636,2))
}
solution = lambda cur,val: [conv[cur](v) for v in val]
def solution(to_cur,values):
if to_cur == 'EUR':
return [f'{val / 1.1363636:,.2f}€' for val in values]
return [f'${val * 1.1363636:,.2f}' for val in values]
def solution(to_cur,value):
rate = 1.1363636
USD = "${:,.2f}".format
EUR = "{:,.2f}€".format
return [USD(cur * rate) if to_cur == "USD" else EUR(cur / rate) for cur in value]
def solution(to_cur,value):
d ={"USD": lambda x: "${:,.2f}".format(x*1.1363636),"EUR": lambda x: "{:,.2f}€".format(x/1.1363636)}
return list(map(d[to_cur], value))
def solution(to_cur,value):
USD_TO_EUR_RATE = 1.1363636
if to_cur == 'USD':
return ['${:,.2f}'.format(round(x * USD_TO_EUR_RATE, 2)) for x in value]
elif to_cur == 'EUR':
return ['{:,.2f}€'.format(round(x / USD_TO_EUR_RATE, 2)) for x in value]
else:
raise valueError
欢迎各位同学加群讨论,一起学习,共同成长!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。