Telegram Group & Telegram Channel
پایتونیک، روشی برای کوتاه کردن و خوانا کردن کدها
پایتون زبان بسیار قدرتمندی است و تقریبا هر برنامه ای می توان با آن نوشت. اما قدرت پایتون در ساده نویسی و کوتاه کردن دستورات برنامه است.
فرض کنید می خواهیم برنامه ای بنویسیم که اعداد زوج مابین 0 تا 100 را با یکدیگر جمع کند. ساختار برنامه نویسی چیزی شبیه زیر خواهد بود:
total=0
for i in range(1,100):
if i%2==0:
total+= i
print(total)
اگر بخواهیم کمی کد فوق را خلاصه کنیم از ساختار زیر هم می توانیم استفاده کنیم:
total=0
for i in range(1,100):
total+= i if i%2==0 else 0
print(total)

اما تمام کدهای فوق را می توانیم با یک خط زیر عوض کنیم:
print(sum(i if i%2==0 else 0 for i in range(1,100)))

کد فوق احتمالا خلاصه ترین و خوانا ترین کدی است که می توان برای این برنامه نوشت، به این شیوه کد نویسی پایتونیک گفته می شود.

#پایتون_مالی
#پایتونیک

#مقدمات
پایتون برای مالی در تلگرام https://www.tg-me.com/us/Python4Finance/com.python4finance
پایتون برای مالی در بله https://ble.im/us/Python4Finance/com.python4finance



tg-me.com/python4finance/44
Create:
Last Update:

پایتونیک، روشی برای کوتاه کردن و خوانا کردن کدها
پایتون زبان بسیار قدرتمندی است و تقریبا هر برنامه ای می توان با آن نوشت. اما قدرت پایتون در ساده نویسی و کوتاه کردن دستورات برنامه است.
فرض کنید می خواهیم برنامه ای بنویسیم که اعداد زوج مابین 0 تا 100 را با یکدیگر جمع کند. ساختار برنامه نویسی چیزی شبیه زیر خواهد بود:
total=0
for i in range(1,100):
if i%2==0:
total+= i
print(total)
اگر بخواهیم کمی کد فوق را خلاصه کنیم از ساختار زیر هم می توانیم استفاده کنیم:
total=0
for i in range(1,100):
total+= i if i%2==0 else 0
print(total)

اما تمام کدهای فوق را می توانیم با یک خط زیر عوض کنیم:
print(sum(i if i%2==0 else 0 for i in range(1,100)))

کد فوق احتمالا خلاصه ترین و خوانا ترین کدی است که می توان برای این برنامه نوشت، به این شیوه کد نویسی پایتونیک گفته می شود.

#پایتون_مالی
#پایتونیک

#مقدمات
پایتون برای مالی در تلگرام https://www.tg-me.com/us/Python4Finance/com.python4finance
پایتون برای مالی در بله https://ble.im/us/Python4Finance/com.python4finance

BY Python4Finance




Share with your friend now:
tg-me.com/python4finance/44

View MORE
Open in Telegram


Python4Finance Telegram | DID YOU KNOW?

Date: |

NEWS: Telegram supports Facetime video calls NOW!

Secure video calling is in high demand. As an alternative to Zoom, many people are using end-to-end encrypted apps such as WhatsApp, FaceTime or Signal to speak to friends and family face-to-face since coronavirus lockdowns started to take place across the world. There’s another option—secure communications app Telegram just added video calling to its feature set, available on both iOS and Android. The new feature is also super secure—like Signal and WhatsApp and unlike Zoom (yet), video calls will be end-to-end encrypted.

Why Telegram?

Telegram has no known backdoors and, even though it is come in for criticism for using proprietary encryption methods instead of open-source ones, those have yet to be compromised. While no messaging app can guarantee a 100% impermeable defense against determined attackers, Telegram is vulnerabilities are few and either theoretical or based on spoof files fooling users into actively enabling an attack.

Python4Finance from us


Telegram Python4Finance
FROM USA