5️⃣ دستورات پایه در پایتون: قسمت پنجم ◀️ یک مجموعه را باز کنید. اگر مجموعهای از مقادیر در یک لیست، تاپل و غیره دارید، پایتون به شما اجازه میدهد که مقادیر را به متغیرها استخراج کنید. به این کار باز کردن بسته بندی (unpacking) میگویند.
🟡 مثال: fruits = ["apple", "banana", "cherry"] x, y, z = fruits print(x) print(y) print(z) خروجی پایتون apple banana cherry
⬅️ متغیرهای خروجی 🟣تابع ()print اغلب برای خروجی متغیرها استفاده میشود. 🟡 مثال: x = "Python is awesome" print(x) خروجی پایتون: Python is awesome
🟣در تابع ()print شما چندین متغیر را که با کاما از هم جدا شدهاند، خروجی میدهید: 🟡 مثال: x = "Python" y = "is" z = "awesome" print(x, y, z) خروجی پایتون: Python is awesome
🟣 همچنین میتوانید از عملگر + برای خروجی چندین متغیر استفاده کنید: 🟡 مثال: x = "Python " y = "is " z = "awesome" print(x + y + z) خروجی پایتون: Python is awesome
‼️ به کاراکتر Space بعد از "Python" و "is" توجه کنید، بدون آنها نتیجه "Pythonisawesome" خواهد بود.
🟣برای اعداد، کاراکتر + به عنوان یک عملگر ریاضی عمل میکند: 🟡 مثال: x = 5 y = 10 print(x + y) خروجی پایتون: 15
🟣در تابع ()print وقتی میخواهید یک رشته و یک عدد را با عملگر + ترکیب کنید، پایتون به شما یک خطا میدهد: 🟡 مثال: x = 5 y = "John" print(x + y) خروجی پایتون: TypeError: unsupported operand type(s) for +: 'int' and 'str'
🟣 بهترین راه برای خروجی چندین متغیر در تابع ()print جدا کردن آنها با کاما است که حتی از انواع دادههای مختلف پشتیبانی میکند: 🟡 مثال: x = 5 y = "John" print(x, y) خروجی پایتون: 5 John
5️⃣ دستورات پایه در پایتون: قسمت پنجم ◀️ یک مجموعه را باز کنید. اگر مجموعهای از مقادیر در یک لیست، تاپل و غیره دارید، پایتون به شما اجازه میدهد که مقادیر را به متغیرها استخراج کنید. به این کار باز کردن بسته بندی (unpacking) میگویند.
🟡 مثال: fruits = ["apple", "banana", "cherry"] x, y, z = fruits print(x) print(y) print(z) خروجی پایتون apple banana cherry
⬅️ متغیرهای خروجی 🟣تابع ()print اغلب برای خروجی متغیرها استفاده میشود. 🟡 مثال: x = "Python is awesome" print(x) خروجی پایتون: Python is awesome
🟣در تابع ()print شما چندین متغیر را که با کاما از هم جدا شدهاند، خروجی میدهید: 🟡 مثال: x = "Python" y = "is" z = "awesome" print(x, y, z) خروجی پایتون: Python is awesome
🟣 همچنین میتوانید از عملگر + برای خروجی چندین متغیر استفاده کنید: 🟡 مثال: x = "Python " y = "is " z = "awesome" print(x + y + z) خروجی پایتون: Python is awesome
‼️ به کاراکتر Space بعد از "Python" و "is" توجه کنید، بدون آنها نتیجه "Pythonisawesome" خواهد بود.
🟣برای اعداد، کاراکتر + به عنوان یک عملگر ریاضی عمل میکند: 🟡 مثال: x = 5 y = 10 print(x + y) خروجی پایتون: 15
🟣در تابع ()print وقتی میخواهید یک رشته و یک عدد را با عملگر + ترکیب کنید، پایتون به شما یک خطا میدهد: 🟡 مثال: x = 5 y = "John" print(x + y) خروجی پایتون: TypeError: unsupported operand type(s) for +: 'int' and 'str'
🟣 بهترین راه برای خروجی چندین متغیر در تابع ()print جدا کردن آنها با کاما است که حتی از انواع دادههای مختلف پشتیبانی میکند: 🟡 مثال: x = 5 y = "John" print(x, y) خروجی پایتون: 5 John
Stocks dropped on Friday afternoon, as gains made earlier in the day on hopes for diplomatic progress between Russia and Ukraine turned to losses. Technology stocks were hit particularly hard by higher bond yields. The regulator said it has been undertaking several campaigns to educate the investors to be vigilant while taking investment decisions based on stock tips. As a result, the pandemic saw many newcomers to Telegram, including prominent anti-vaccine activists who used the app's hands-off approach to share false information on shots, a study from the Institute for Strategic Dialogue shows. As such, the SC would like to remind investors to always exercise caution when evaluating investment opportunities, especially those promising unrealistically high returns with little or no risk. Investors should also never deposit money into someone’s personal bank account if instructed. Under the Sebi Act, the regulator has the power to carry out search and seizure of books, registers, documents including electronics and digital devices from any person associated with the securities market.
from tw