How to find N-Largest and N-Smallest Numbers in Python!

Опубликовано: 24 Июль 2022
на канале: Patrick Loeber
131,434
8.8k

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 :   / discord  

If you enjoyed this video, please subscribe to the channel:
▶️ :    / @patloeber  

~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

🖥️ Website: https://www.python-engineer.com
🐦 Twitter -   / patloeber  
✉️ Newsletter - https://www.python-engineer.com/newsl...
📸 Instagram -   / patloeber  
🦾 Discord:   / discord  
▶️ Subscribe:    / @patloeber  

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅿 Patreon -   / patrickloeber  

#Python #shorts


Смотрите видео How to find N-Largest and N-Smallest Numbers in Python! онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Patrick Loeber 24 Июль 2022. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 131,434 раз и оно понравилось 8.8 тысяч посетителям.