+ 1

What is the difference between this 2 code?

This task is at functional programming -> lambda -> the task name: How much? I needed to calculate the percentage of a given price and i wrote the first code that was wrong at test case #4, but the 2nd is correct. The difference is at 《res=...》 price = int(input()) perc = int(input()) res = (lambda x,y: x/100*y) (price, perc) print(res) price = int(input()) perc = int(input()) res = (lambda x,y: x*y/100) (price, perc) print(res)

14th Apr 2022, 11:21 AM
Peter Kosa
1 Antwort
+ 3
It's a floating point precision issue. https://code.sololearn.com/c5n1pu7nUCUX/?ref=app
14th Apr 2022, 11:31 AM
Lisa
Lisa - avatar