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 SC urges the public to refer to the SC’s I nvestor Alert List before investing. The list contains details of unauthorised websites, investment products, companies and individuals. Members of the public who suspect that they have been approached by unauthorised firms or individuals offering schemes that promise unrealistic returns Since January 2022, the SC has received a total of 47 complaints and enquiries on illegal investment schemes promoted through Telegram. These fraudulent schemes offer non-existent investment opportunities, promising very attractive and risk-free returns within a short span of time. They commonly offer unrealistic returns of as high as 1,000% within 24 hours or even within a few hours. Asked about its stance on disinformation, Telegram spokesperson Remi Vaughn told AFP: "As noted by our CEO, the sheer volume of information being shared on channels makes it extremely difficult to verify, so it's important that users double-check what they read." Overall, extreme levels of fear in the market seems to have morphed into something more resembling concern. For example, the Cboe Volatility Index fell from its 2022 peak of 36, which it hit Monday, to around 30 on Friday, a sign of easing tensions. Meanwhile, while the price of WTI crude oil slipped from Sunday’s multiyear high $130 of barrel to $109 a pop. Markets have been expecting heavy restrictions on Russian oil, some of which the U.S. has already imposed, and that would reduce the global supply and bring about even more burdensome inflation. But because group chats and the channel features are not end-to-end encrypted, Galperin said user privacy is potentially under threat.
from it


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