Telegram Group & Telegram Channel
🎲#گام_به_گام

💻 کدنویسی

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

◀️ ادامه دارد....

#️⃣#کدنویسی
#️⃣#IDSchools
#️⃣#IDS
#️⃣#IDS_Math

✉️@IDSchools
✉️@IDS_Math
Please open Telegram to view this post
VIEW IN TELEGRAM



group-telegram.com/IDS_Math/118
Create:
Last Update:

🎲#گام_به_گام

💻 کدنویسی

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

◀️ ادامه دارد....

#️⃣#کدنویسی
#️⃣#IDSchools
#️⃣#IDS
#️⃣#IDS_Math

✉️@IDSchools
✉️@IDS_Math

BY ریاضی، آمار و علوم کامپیوتر - مدارس میان‌رشته‌ای


Warning: Undefined variable $i in /var/www/group-telegram/post.php on line 260

Share with your friend now:
group-telegram.com/IDS_Math/118

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

The Russian invasion of Ukraine has been a driving force in markets for the past few weeks. At the start of 2018, the company attempted to launch an Initial Coin Offering (ICO) which would enable it to enable payments (and earn the cash that comes from doing so). The initial signals were promising, especially given Telegram’s user base is already fairly crypto-savvy. It raised an initial tranche of cash – worth more than a billion dollars – to help develop the coin before opening sales to the public. Unfortunately, third-party sales of coins bought in those initial fundraising rounds raised the ire of the SEC, which brought the hammer down on the whole operation. In 2020, officials ordered Telegram to pay a fine of $18.5 million and hand back much of the cash that it had raised. Either way, Durov says that he withdrew his resignation but that he was ousted from his company anyway. Subsequently, control of the company was reportedly handed to oligarchs Alisher Usmanov and Igor Sechin, both allegedly close associates of Russian leader Vladimir Putin. For Oleksandra Tsekhanovska, head of the Hybrid Warfare Analytical Group at the Kyiv-based Ukraine Crisis Media Center, the effects are both near- and far-reaching. The fake Zelenskiy account reached 20,000 followers on Telegram before it was shut down, a remedial action that experts say is all too rare.
from sg


Telegram ریاضی، آمار و علوم کامپیوتر - مدارس میان‌رشته‌ای
FROM American