+ 2
Python Lambda Practice
I am going through Lambda lesson practice of Python Intermediate and when I write and run the code one case is not passing correctly (Case 4). Please check and provide feedback 😊 This is my code snippet: price = int(input()) perc = int(input()) res = (lambda x,y: (x/100)*y)(price, perc) print(res)
5 odpowiedzi
+ 1
x * y / 100
Try this
0
Yeah it is working, but may I know why my approach is not working 100%
0
Try this:
price = 80
perc = 7
res_1 = (lambda x,y: (x/100)*y)(price, perc) # your solution
res_2 = (lambda x,y: x * y / 100)(price, perc) # AJ solution
print('Your solution:', res_1, '\nAJ solution:', res_2)
0
Wakil Ahmad Hamidi
Because 99 / 100 would be 0 so 0 * 10 = 0
but 99 * 10 / 100 would be 9.9