How to find N-Largest and N-Smallest Numbers in Python!
Quick Python tip how to efficiently find the n largest or smallest numbers of a List.
A note from the official docs: “The latter two functions perform best for smaller values of n. For larger values, it is more efficient to use the sorted() function. Also, when n==1, it is more efficient to use the built-in min() and max() functions. If repeated usage of these functions is required, consider turning the iterable into an actual heap.”
⭐ Join Our Discord : https://discord.gg/FHMg9tKFSN
If you enjoyed this video, please subscribe to the channel:
▶️ : https://www.youtube.com/channel/UCbXgNpp0jedKWcQiULLbDTA?sub_confirmation=1
~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~
🖥️ Website: https://www.python-engineer.com
🐦 Twitter – https://twitter.com/python_engineer
✉️ Newsletter – https://www.python-engineer.com/newsletter
📸 Instagram – https://www.instagram.com/patloeber
🦾 Discord: https://discord.gg/FHMg9tKFSN
▶️ Subscribe: https://www.youtube.com/channel/UCbXgNpp0jedKWcQiULLbDTA?sub_confirmation=1
~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~
🅿 Patreon – https://www.patreon.com/patrickloeber
#Python #shorts