Telegram Group & Telegram Channel
3 трюка с itertools

Начнем с функции combinations: она позволяет составлять комбинации элементов из итерируемых объектов без повторений. Первый аргумент это сам объект, а второй — длина комбинации.

Для того, чтобы составить комбинацию с повторениями, используют функцию combinations_with_replacement. Делает она абсолютно все то же самое что и предыдущая, с одним исключением – теперь в комбинации могут быть повторы.

Ну и в заключение, рассмотрим функцию compress, применяющую "маску" из второго аргумента функции к первому. То есть, если в маске на этом месте стоит единица, то в исходном массиве элемент остается нетронутым, и наоборот.

#itertools



tg-me.com/python_academy/603
Create:
Last Update:

3 трюка с itertools

Начнем с функции combinations: она позволяет составлять комбинации элементов из итерируемых объектов без повторений. Первый аргумент это сам объект, а второй — длина комбинации.

Для того, чтобы составить комбинацию с повторениями, используют функцию combinations_with_replacement. Делает она абсолютно все то же самое что и предыдущая, с одним исключением – теперь в комбинации могут быть повторы.

Ну и в заключение, рассмотрим функцию compress, применяющую "маску" из второго аргумента функции к первому. То есть, если в маске на этом месте стоит единица, то в исходном массиве элемент остается нетронутым, и наоборот.

#itertools

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/603

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

The Singapore stock market has alternated between positive and negative finishes through the last five trading days since the end of the two-day winning streak in which it had added more than a dozen points or 0.4 percent. The Straits Times Index now sits just above the 3,060-point plateau and it's likely to see a narrow trading range on Monday.

Telegram and Signal Havens for Right-Wing Extremists

Since the violent storming of Capitol Hill and subsequent ban of former U.S. President Donald Trump from Facebook and Twitter, the removal of Parler from Amazon’s servers, and the de-platforming of incendiary right-wing content, messaging services Telegram and Signal have seen a deluge of new users. In January alone, Telegram reported 90 million new accounts. Its founder, Pavel Durov, described this as “the largest digital migration in human history.” Signal reportedly doubled its user base to 40 million people and became the most downloaded app in 70 countries. The two services rely on encryption to protect the privacy of user communication, which has made them popular with protesters seeking to conceal their identities against repressive governments in places like Belarus, Hong Kong, and Iran. But the same encryption technology has also made them a favored communication tool for criminals and terrorist groups, including al Qaeda and the Islamic State.

Python Academy from sa


Telegram Python Academy
FROM USA