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

Although some channels have been removed, the curation process is considered opaque and insufficient by analysts. Unlike Silicon Valley giants such as Facebook and Twitter, which run very public anti-disinformation programs, Brooking said: "Telegram is famously lax or absent in its content moderation policy." This ability to mix the public and the private, as well as the ability to use bots to engage with users has proved to be problematic. In early 2021, a database selling phone numbers pulled from Facebook was selling numbers for $20 per lookup. Similarly, security researchers found a network of deepfake bots on the platform that were generating images of people submitted by users to create non-consensual imagery, some of which involved children. Despite Telegram's origins, its approach to users' security has privacy advocates worried. Additionally, investors are often instructed to deposit monies into personal bank accounts of individuals who claim to represent a legitimate entity, and/or into an unrelated corporate account. To lend credence and to lure unsuspecting victims, perpetrators usually claim that their entity and/or the investment schemes are approved by financial authorities.
from br


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