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

Резултати

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

Пребарај: #fuelcrisis

当前筛选 #fuelcrisis清除筛选
International News

@intnewsagency · Post #8923 · 26.03.2026 г., 05:17

Asia Reimposes Covid-Like Measures Amid Fuel Crisis Amid Middle East tensions, Asian countries are reintroducing Covid-era restrictions to save fuel and electricity. The Philippines cuts government workweeks, Pakistan shifts some staff to remote work and closes schools for two weeks, while Sri Lanka declares Wednesday a holiday. Singapore and Thailand urge energy-saving by raising AC temperatures and reducing transport use. #Asia#Energy#FuelCrisis#Conservation The main news of Russia and the world ishere.

International News

@intnewsagency · Post #9402 · 28.04.2026 г., 10:40

Nigerian Aviation Faces Fuel Crisis Amid Oil Boom In Nigeria, jet fuel prices have surged by 270%, compared to just 70% across Africa, says Air Peace CEO Allen Onyeama. Airlines are cutting routes and fleets, struggling to survive. Paradoxically, the Dangote refinery, with record profits, exports kerosene to Europe while national aviation suffers severe fuel shortages. “Businesses are literally printing money while planes wait to refuel.” #Nigeria#aviation#fuelcrisis#oil#Africa The main news of Russia and the world ishere.

የሆርሙዝ መዘጋት እና የነዳጅ ዋጋ መናር በዓለም ኢኮኖሚ ላይ የደቀነው ስጋት ****************** በአሜሪካ እና በእስራኤል ጥምረት በኢራን ላይ የተሰነዘረውን ጥቃት ተከትሎ በመካከለኛው ምሥራቅ በተከሰተው ጦርነት የሆርሙዝ የባሕር ወሽመጥ በመዘጋቱ፣ ዓለም አቀፉ የነዳጅ ገበያና ኢኮኖሚ ከፍተኛ ቀውስ ውስጥ ወድቋል። ይህንኑ ተከትሎ ከ85 በላይ ሀገራት የነዳጅ ዋጋ ጭማሪ አድርገዋል። በአሜሪካ የ20 በመቶ ጭማሪ ሲታይ፣ በእስያ ሀገራት (እንደ ቬየትናም እና ላኦስ) ከ33 እስከ 50 በመቶ የሚደርስ አስከፊ የዋጋ ንረት ተመዝግቧል። ጃፓን እና ፈረንሳይ የስትራቴጂክ የነዳጅ ክምችታቸውን ለመልቀቅ ተገድደዋል። ደቡብ ኮሪያ ከ30 ዓመታት በኋላ ለመጀመሪያ ጊዜ የነዳጅ ዋጋ የጣሪያ ገደብ አውጥታለች። የቡድን ሰባት ሀገራት የፋይናንስ ሚኒስትሮች የአቅርቦት እጥረቱን ለመታደግ አስቸኳይ ስብሰባ ተቀምጠዋል። እንደ ፓኪስታን እና ባንግላዴሽ ያሉ ሀገራት ፍጆታን ለመቀነስ ትምህርት ቤቶችን እስከመዝጋት ደርሰዋል። ቀውሱ ከነዳጅ አልፎ በምግብ ዋስትና፣ በማዳበሪያ አቅርቦት እና በኢንዱስትሪ ምርቶች (ፕላስቲክ እና ጨርቃጨርቅ) ላይ ከፍተኛ የዋጋ ጫና ፈጥሯል። የኢኮኖሚ ባለሙያዎች ሁኔታው ወደ ‘ስታግፍሌሽን’ (የዋጋ ንረትና የኢኮኖሚ መቀዝቀዝ ጥምረት) ሊያመራ እንደሚችል እና ዓለም አቀፍ የኑሮ ቀውስ ሊያስከትል እንደሚችል እያሰገነዘቡ ነው። በለሚ ታደሰ ሙሉ መረጃውን ለማንበብ እዚህ ይጫኑ #FuelCrisis#GlobalEconomy#EnergySecurity#IranWarImpact#OilPrices2026#G7Summit

Addis Standard

@addisstandardeng · Post #21936 · 03.04.2026 г., 16:30

#Premiering_now: The Standard Signal | Ep.15: Ethiopia Under Pressure: Fuel Crisis, Global & Regional Instability, a Fragile Election | Jawar Mohammed Click here to watch: https://www.youtube.com/watch?v=HexAbPk8Dkw Ethiopia is facing mounting pressures. In Episode 15 of The Standard Signal, host Tsedale Lamma brings Jawar Mohammed to discuss the deepening fuel shortage and corruption concerns in Ethiopia, the looming fertilizer crisis and its implications for food security, and the impact of Middle East war on Ethiopia’s economy and stability. #AddisStandard#TheStandardSignal#Ethiopia#JawarMohammed#EthiopiaPolitics#Corruption#FuelCrisis#HornOfAfrica#Tigray#Amhara#Oromia#EthiopiaElection#AfricaPolitics#EthiopiaNews#AfricanPolitics#Geopolitics

Addis Standard

@addisstandardeng · Post #21935 · 03.04.2026 г., 14:30

#Coming_UP: The Standard Signal | Ep.15: Ethiopia Under Pressure: Fuel Crisis, Global & Regional Instability, a Fragile Election | Jawar Mohammed #TsedaleLemma speaks with #JawarMohammed about the growing challenges facing Ethiopia, from global and regional tensions to domestic instability, corruption and Ethiopia’s fragile election. Premiers at: 7:30 PM EAT tonight. Subscribe to watch: https://www.youtube.com/@AddisStandard #AddisStandard#TheStandardSignal#Ethiopia#JawarMohammed#EthiopiaPolitics#Corruption#FuelCrisis#HornOfAfrica#Tigray#Amhara#Oromia#EthiopiaElection#AfricaPolitics#EthiopiaNews#AfricanPolitics#Geopolitics