PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#task: 7% tax if p <= 20 else tax free
#with lambda
#question: how to avoid to write tree times float before x?
p= ['2','10','80','99']
#print(p1)
res3 = list(map(lambda x: float(x) *1.07 if float(x) <= 20 else float(x),p))
print(sum(res3))
#without tree times float before x
res4 = list(map(lambda x: x *1.07 if x <= 20 else x,[float(i) for i in p]))
print(sum(res4))
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run