Ранее я уже упоминал о другой фишке из ˍˍ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
Give your pre-loved items a new lease of life!
Let's do our part and pass on the love in the cycle of joy. 🧸📦
Visit go.gov.sg/donate-resell-repair for the list of donation, resale and repair channels.
#Donate#SustainableSG#TowardsZeroWaste#LunarNewYear2024
🥳 Поддержите нас
🥳
Выразите свою любовь небольшим пожертвованием! Каждый вклад помогает нам доставлять вам больше улыбок. Спасибо за вашу поддержку! 😇
#donate#support#gift#ton
Hello Learners..
Have a small request to all of you.
As you can see our web hosting plan is ended. And we're providing a 100% paid free courses for you.
If you guys like our services & wanted to continue to get in touch then courseunity needs your help.
Donate a little vibe :
paypal.me/adventurepatel
GPay :
er.adventurepatel@okaxis
🙏 Thanks for the support 🙏
#donate#donatetoday#donationsneeded#donatenow#donanım
#TaxTip Enjoy tax deductions of 2.5 times the qualifying donation amount in Year of Assessment 2023 when you donate to any approved Institution of a Public Character (IPC) by 31 Dec 2022!
You will not need to declare the donation amount in your income tax return as tax deductions for qualifying donations will be automatically reflected in your tax assessments based on information from the IPC.
Details and qualifying conditions: https://www.iras.gov.sg/taxes/other-taxes/charities/donations-tax-deductions
#iras#sg#taxes#taxtip#reliefs#donate#donations