TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #156 · 2 окт.

Те, кто в Python не первый день, хорошо знают, что на число можно умножить не только число, но и другие типы. Главное, чтобы у этих типов была реализация такой операции. # list >>> [1] * 3 [1, 1, 1] # tuple >>> (2, 3) * 3 (2, 3, 2, 3, 2, 3) # string >>> "A" * 3 "AAA" Так работает полиморфизм стандартных типов. Интересно здесь то, что это сработает и в том случае, когда порядок операндов обратный. То есть int умножить на [тип]. # list >>> 3 * [1] [1, 1, 1] # tuple >>> 3 * (2, 3) (2, 3, 2, 3, 2, 3) # string >>> 3 * "A" "AAA" Если хотите реализовать такое поведение в ваших классах то следует помнить два момента: 1. Если множитель справа, то вам нужно реализовать метод __mul__, наш класс это первый операнд, то есть слева. myType * 3 2. Если множитель слева, то вам нужно реализовать метод __rmul__, наш класс это второй операнд, справа. 3* myType Всё тоже самое можно делать и для других математических операторов. И если в этом примере действие и результат будут фактически одинаковыми, то бывают ситуации, когда это не так. Например, при умножении матриц имеет значение порядок операндов. Для других операторов, таких как деление или сдвиг, очень важно кто с какой стороны находится. >>> 2/4, 4/2 (0.5, 2.0) >>> 2<<3, 3<<2 (16, 12) >>> 100%15, 15%100 (10, 15) #tricks#basic

Резултати

Пронајдени 51 слични објави

Пребарај: #clouds

当前筛选 #clouds清除筛选
Amazing Geography 🌍

@amazingeo · Post #587 · 22.01.2026 г., 20:31

🌍 Polar stratospheric clouds, also known as nacreous clouds, shimmer with pastel colors and only form in extremely cold conditions. They set the stage for both rare atmospheric optics and ozone loss. ✨ #aurora⚡#clouds⚡#atmosphere⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #511 · 13.12.2025 г., 12:31

🌍 The highest clouds on Earth are called noctilucent clouds. They glow at twilight and form up to 85 kilometers above ground, in the edge of space—far higher than any weather clouds. ✨ #meteorology⚡#clouds⚡#atmosphere⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #519 · 08.08.2025 г., 00:22

🌎 The horseshoe vortex, or “smoke ring” in the sky, is a rare weather phenomenon where winds sculpt swirling, donut-shaped clouds. These dramatic rings form after volcanic eruptions, industrial blasts, or even lightning, showcasing nature’s surprising ability to twist air into geometric shapes. ✨ #atmosphere⚡#clouds⚡#weather 👉subscribe Interesting Planet

Universe Mysteries 🪐

@cosmomyst · Post #84 · 05.08.2025 г., 13:11

🪐 In the atmosphere of the giant planet Neptune, astronomers have discovered clouds of methane ice drifting in bands, creating ghostly streaks against the blue background. These shimmering clouds form when sunlight breaks apart methane gas and turns it into icy crystals high above the planet’s swirling, windy storms. ✨ #Neptune⚡#planets⚡#clouds⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

ПретходнаСтраница 1 од 5Следна