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: |

Some people used the platform to organize ahead of the storming of the U.S. Capitol in January 2021, and last month Senator Mark Warner sent a letter to Durov urging him to curb Russian information operations on Telegram. Telegram, which does little policing of its content, has also became a hub for Russian propaganda and misinformation. Many pro-Kremlin channels have become popular, alongside accounts of journalists and other independent observers. "The inflation fire was already hot and now with war-driven inflation added to the mix, it will grow even hotter, setting off a scramble by the world’s central banks to pull back their stimulus earlier than expected," Chris Rupkey, chief economist at FWDBONDS, wrote in an email. "A spike in inflation rates has preceded economic recessions historically and this time prices have soared to levels that once again pose a threat to growth." The company maintains that it cannot act against individual or group chats, which are “private amongst their participants,” but it will respond to requests in relation to sticker sets, channels and bots which are publicly available. During the invasion of Ukraine, Pavel Durov has wrestled with this issue a lot more prominently than he has before. Channels like Donbass Insider and Bellum Acta, as reported by Foreign Policy, started pumping out pro-Russian propaganda as the invasion began. So much so that the Ukrainian National Security and Defense Council issued a statement labeling which accounts are Russian-backed. Ukrainian officials, in potential violation of the Geneva Convention, have shared imagery of dead and captured Russian soldiers on the platform. Some privacy experts say Telegram is not secure enough
from us


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