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

Telegram Auto-Delete Messages in Any Chat

Some messages aren’t supposed to last forever. There are some Telegram groups and conversations where it’s best if messages are automatically deleted in a day or a week. Here’s how to auto-delete messages in any Telegram chat. You can enable the auto-delete feature on a per-chat basis. It works for both one-on-one conversations and group chats. Previously, you needed to use the Secret Chat feature to automatically delete messages after a set time. At the time of writing, you can choose to automatically delete messages after a day or a week. Telegram starts the timer once they are sent, not after they are read. This won’t affect the messages that were sent before enabling the feature.

Telegram hopes to raise $1bn with a convertible bond private placement

The super secure UAE-based Telegram messenger service, developed by Russian-born software icon Pavel Durov, is looking to raise $1bn through a bond placement to a limited number of investors from Russia, Europe, Asia and the Middle East, the Kommersant daily reported citing unnamed sources on February 18, 2021.The issue reportedly comprises exchange bonds that could be converted into equity in the messaging service that is currently 100% owned by Durov and his brother Nikolai.Kommersant reports that the price of the conversion would be at a 10% discount to a potential IPO should it happen within five years.The minimum bond placement is said to be set at $50mn, but could be lowered to $10mn. Five-year bonds could carry an annual coupon of 7-8%.

Python4Finance from id


Telegram Python4Finance
FROM USA