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/hk/Python4Finance/com.python4finance
پایتون برای مالی در بله https://ble.im/hk/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/hk/Python4Finance/com.python4finance
پایتون برای مالی در بله https://ble.im/hk/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: |

Export WhatsApp stickers to Telegram on iPhone

You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.

Python4Finance from hk


Telegram Python4Finance
FROM USA