Ранее я уже упоминал о другой фишке из ˍˍfutureˍˍ , это оператор деления.
from __future__ import division
Суть проста. Раньше сложность типа данных результата поределялась типом самого сложного операнда.
Например:
int/int => int
int/float => float
В первом случае оба операнда int, значит и результат будет int. Во втором float более сложный тип, поэтому результат будет float.
Если нам требуется получить дробное значение при делении двух int то приходилось форсированно один из операндов конверировать в float.
12/float(5) => float
Но с новой "философией" это не требуется. В Python3 "floor division" заменили на "true division" а старый способ теперь работает через оператор "//".
>>> 3/2
1.5
>>> 3//2
1
То есть теперь деление int на int даёт float если результат не целое число.
В классах теперь доступны методы __floordiv__() и __truediv__() для определения поведения с этими операторами.
Данный переход описан в PEP238.
#pep#2to3#basic
📰 AI News Update: 🤖
In the world of artificial intelligence, researchers have made significant strides in natural language processing. A new model developed by a team at a leading university has surpassed previous benchmarks in understanding context and nuances in text. This advancement could revolutionize chatbots, translation services, and content analysis tools.
Moreover, a breakthrough in AI ethics has been achieved with the development of a framework that prioritizes fairness and transparency in machine learning algorithms. This approach aims to mitigate biases and discrimination, ensuring AI systems make ethical decisions in various applications.
On the business front, tech giants are investing heavily in AI-driven solutions to enhance customer experiences and streamline operations. Companies across industries are increasingly leveraging AI to drive innovation...
➖➖➖➖🔻
🤖 BOT: @Chatgpt_OfficialBOT
💎@Chatgpt_OfficialNews
#️⃣#NeuralHubAI#ReferralContest#EarnTokens#WeeklyAirdrop
➖➖➖➖🔺
🚀 Referral Contest Heating Up – $200 Weekly Prize!
The race is ON, and here are your current top referrers:
🥇Amir – 30 referrals
🥈Pixel Wiz* – 29 referrals
🥉Ref Champ* – 23 referrals
But it’s not over yet — you still have time to climb the leaderboard and win your share of the $200 prize this week!
⚡️Just invite your friends using your referral link
😵Every referral brings you closer to the top
🏆Top 3 win: $100 • $60 • $40
Let’s go! Start inviting now and grab that top spot! 📈
➖➖➖➖🔻
🤖 BOT: @Chatgpt_OfficialBOT
💎@Chatgpt_OfficialNews
#️⃣#NeuralHubAI#ReferralContest#EarnTokens#WeeklyAirdrop
➖➖➖➖🔺
By participating in our airdrop campaign, you will not only get a chance to earn JIM tokens, but you will also get an opportunity to be a part of the most revolutionary project of the year. So, don't miss out on this amazing opportunity and join us now! 🙌
https://gleam.io/CmtmH/jimmy-project-airdrop-campaign
Spread the word and invite your friends to join the Jimmy project community. Together, we will soar to new heights!🚀#JimmyProject#Airdrop#Cryptocurrency#Blockchain#EarnTokens#JoinUsNow
Total $25.000 worth JIM Token supply will be distributed to participants according to points collected. Complete all tasks to benefit airdrop in full!
10 Referral Champions will share 1000 USDT Prize pool!