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

And indeed, volatility has been a hallmark of the market environment so far in 2022, with the S&P 500 still down more than 10% for the year-to-date after first sliding into a correction last month. The CBOE Volatility Index, or VIX, has held at a lofty level of more than 30. 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. 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. The Dow Jones Industrial Average fell 230 points, or 0.7%. Meanwhile, the S&P 500 and the Nasdaq Composite dropped 1.3% and 2.2%, respectively. All three indexes began the day with gains before selling off. "The argument from Telegram is, 'You should trust us because we tell you that we're trustworthy,'" Maréchal said. "It's really in the eye of the beholder whether that's something you want to buy into."
from kr


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