Ранее я уже упоминал о другой фишке из ˍˍ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
Big news for Apple users! 🍏✨ Did you hear? Apple has finally allowed emulators on iOS, and Delta stands out as one of the best out there! 🎮 Have you given it a try yet? Share your thoughts below! #iOS#Emulators#Delta
🌍 The Mississippi River Delta’s vast freshwater wetlands act as a natural filter, removing pollutants and buffering storm surges. These shifting marshes shelter over 400 species of fish and wildlife. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Okavango Delta in southern Africa floods seasonally with rainwater from distant highlands, creating vast, ever-shifting freshwater wetlands that support hundreds of rare animal species. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Danube Delta in Eastern Europe contains over 30 distinct types of freshwater wetlands, making it one of the most biodiverse delta systems in the world outside the tropics. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Ethiopia’s Lake Tana is the source of the Blue Nile and is surrounded by freshwater wetlands that support dozens of bird species found nowhere else, making it a hotspot for endemic wildlife. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 River deltas like Vietnam’s Mekong and the Mississippi in the US form complex freshwater wetlands, creating twisting channels and islands that shelter rare fish, birds, and vital crops. ✨
#wetlands⚡#delta⚡#biodiversity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Wetlands in the Siberian taiga freeze solid each winter, yet come alive in spring to host millions of migrating birds. These seasonal deltas become some of the world’s richest breeding grounds. ✨
#wetlands⚡#delta⚡#migration⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The Okavango Delta in Botswana is one of the few major river deltas that forms entirely inland, creating a lush wetland oasis in the middle of the Kalahari Desert. ✨
#rivers⚡#wetlands⚡#delta⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The Sudd in South Sudan is the largest freshwater wetland in the Nile basin. During flood season, its floating reeds can form islands that drift for kilometers across the swamp’s surface. ✨
#wetlands⚡#delta⚡#Africa⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Some freshwater wetlands and deltas trap so much carbon in their soil that, hectare for hectare, they store more than most forests—making them powerful natural climate regulators. ✨
#wetlands⚡#delta⚡#carbon⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Florida Everglades, a vast freshwater wetland, is the only place on Earth where alligators and crocodiles coexist in the wild, thanks to its unique mix of habitats and water conditions. ✨
#wetlands⚡#delta⚡#wildlife⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍