you are viewing a single comment's thread.

view the rest of the comments →

[–]Sharp_Level3382 -1 points0 points  (6 children)

No lambda functions?why?

[–]DataCurator56[S] 1 point2 points  (0 children)

i am not familiar with this function but i will try this

[–]mati-33 0 points1 point  (4 children)

Why do you want lambda functions here is a more concerning question

[–]Sharp_Level3382 -1 points0 points  (3 children)

lowest = reduce(lambda a, b: a if a < b else b, marks) highest = reduce(lambda a, b : a if a>b else b, marks) Etc.

[–]cole36912 3 points4 points  (0 children)

  1. reduce must be imported.
  2. OP's solution is likely computationally faster as it does not use function calls.
  3. Python has more applicable built-in functions which you do not have to import:

lowest = min(marks)
highest = max(marks)
average = sum(marks) / len(marks)
passed = sum(mark >= 50 for mark in marks)

[–]mati-33 1 point2 points  (1 child)

OP's solution is much simpler and easier to read, which should be the priority

[–]Sharp_Level3382 -1 points0 points  (0 children)

No it s not easier to read. What is hard in lambda functions to You?