Ранее я уже упоминал о другой фишке из ˍˍ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
Multipurpose Court Project
Bishoftu,Ethiopia
Construction on the new basketball court at Hibret (Tokuma) Elementary School is progressing smoothly and is nearly halfway complete. We're excited about the progress and are on track to achieve our goal.
Your support is crucial to ensure the project's successful completion.
Our goal is to create a vibrant playground for the children of Hibret School.
Play is not a privilege; it's a life skill. Every child deserves a place to play!
To contribute and support us please contact us at:
[email protected]
#Playground#AllDeserveToPlay
#Rotaract_Kuriftu
#Rotary
#100yearsofserviceinafrica
#Rotaract
#District9212
#RotaractEthiopia
Follow Us:
Facebook | Twitter | Instagram | Telegram | LinkedIn
YES! 🙌 It's a wrap! 🥳
The HaraCoders Bootcamp training, brought to you by the awesome Rotaract Club of Kuriftu 🤝, BuildX Ethiopia , Sira Ale, and Addis Ababa University College of Veterinary Medicine and Agriculture , has been a HUGE success!
We're sending out waves of gratitude to everyone involved and a BIG congrats to our fantastic trainees! 🎉
So proud of you all! 🔥
Stay tuned... round 2 might be closer than you think! 😉🚀
#AddisCoders#BuildXEthiopia#TechForAll#EmpowerTheFuture#CodingBootCamp#EthiopianTech#LearnToCode#CodingForChange
#Rotary
#Rackuriftu
#100yearsofserviceinafrica
#Rotaract
#District9212
#RotaractEthiopia
🚀 Exciting News! 🚀
The AddisCoders BootCamp is brought to you by BuildX Ethiopia in partnership with Rotaract Kuriftu, SERRALE, and Addis Ababa University! 🎓💻
Together, we’re empowering Ethiopian youth with hands-on web development skills to build the future of tech! 🔥
Stay tuned for more updates!
#AddisCoders#BuildXEthiopia#TechForAll#EmpowerTheFuture#CodingBootCamp#EthiopianTech#LearnToCode#CodingForChange
#Rotary
#Rackuriftu
#100yearsofserviceinafrica
#Rotaract
#District9212
#RotaractEthiopia