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

Резултати

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

Пребарај: #studentexchange

当前筛选 #studentexchange清除筛选
Green University CA | Official

@centralasian_greenuniversity · Post #181 · 09.10.2025 г., 07:35

🇫🇷French Ambassador Visits Green University 📌On October 8, 2025, Green University welcomed H.E. Mr. Walid Fouque, the Ambassador of France to Uzbekistan. 💬During the meeting, exciting opportunities for cooperation were discussed — including student exchange programs with top French universities starting from 2026, visits by French experts, creation of a French Language Center, joint research projects, and internships with French companies! 💬As a next step, our university leadership has been invited to visit France this November (10–20) to kick off these partnerships and connect with universities, research centers, and industry reps. #GreenUniversity#France#InternationalCooperation#StudentExchange#StudyAbroad ✉️ [email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #1006 · 06.04.2026 г., 17:59

Green University Hosts OSCE Academy Delegation 💬Green University welcomed a delegation from the OSCE Academy in Bishkek! During the meeting, Rector Professor Bakhtiyor Pulatov and Anja Mihr discussed cooperation opportunities and reached an agreement on the Student Exchange Program. 💬 Dr. Anja Mihr delivered a presentation for students on Sustainable Development, sharing valuable insights on global challenges and opportunities for youth engagement. 🤝 This visit marks an important step in expanding international cooperation and providing students with new academic and global experiences. #GreenUniversity#OSCEAcademy#StudentExchange#SustainableDevelopment#InternationalCooperation#GlobalExperience 👉ReadMore _____________________ Green University’da YXHT Akademiyasi delegatsiyasi qabul qilindi 💬Green University Bishkekdagi YXHT Akademiyasi delegatsiyasini qabul qildi! Uchrashuv davomida professor Baxtiyor Pulatov va Anja Mihr hamkorlik imkoniyatlarini muhokama qilib, talabalar almashinuvi dasturi bo‘yicha kelishuvga erishildi. 💬 Dr. Anja Mihr talabalarga Barqaror rivojlanish (Sustainable Development) mavzusida taqdimot o‘tkazdi, global muammolar va yoshlar uchun imkoniyatlar haqida qimmatli ma’lumotlar berdi. 🤝Bu tashrif xalqaro hamkorlikni kengaytirish va talabalarimizga yangi akademik tajribalar yaratish yo‘lida muhim qadam bo‘ldi. #GreenUniversity#OSCEAcademy#TalabalarAlmashinuvi#SustainableDevelopment#XalqaroHamkorlik#GlobalTajriba 👉Batafsil ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube