Ранее я уже упоминал о другой фишке из ˍˍ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
🌎 Ancient lake beds called "playa lakes" preserve natural records of Earth's past. Layers of sediment in these basins capture pollen, plant remains, and even insect fossils, revealing climate cycles and environmental shifts over thousands of years. Some dry lakebeds in the U.S. Southwest show records going back 120,000 years. ✨
#geology⚡#paleoclimate⚡#lakes
👉subscribe Interesting Planet
👉more Channels
🌍 Canada has more lakes than any other country, and many are so large they contain whole islands with their own lakes—making some islands-in-a-lake-on-an-island truly unique on Earth. ✨
#islands⚡#archipelago⚡#lakes⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Africa’s Lake Victoria is the largest tropical lake in the world. Its outflow forms the start of the Nile River, which journeys over 6,600 kilometers north to the Mediterranean Sea. ✨
#lakes⚡#rivers⚡#Africa⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌎 The salt-loving halophiles of California’s pink Lake Hillier thrive where few others survive. These tiny microbes give the lake its vivid color by producing pigments that protect them from extreme salt and sunlight—turning the water a bubblegum pink! ✨
#microbes⚡#pigment⚡#lakes
👉subscribe Interesting Planet
🌍 Russia’s Lake Karachay is so contaminated from past nuclear waste that standing on its shore for just an hour could be fatal—one of the most polluted lakes on the planet. ✨
#rivers⚡#lakes⚡#pollution⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Some lake water can take hundreds of years to fully circulate from the surface to the deepest layers and back again, creating slow, hidden water cycles that influence local climates and ecosystems. ✨
#hydrology⚡#lakes⚡#cycles⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Some of the world’s oldest lakes, like Lake Ohrid in Europe, have existed for more than one million years, preserving unique species found nowhere else on Earth. ✨
#lakes⚡#biodiversity⚡#longevity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Siberia’s Lake Baikal freezes in winter, forming ice so clear that cracks and bubbles can be seen meters deep. In spring, melting ice creates musical sounds as it shifts and breaks apart. ✨
#lakes⚡#rivers⚡#Siberia⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Lake Titicaca, perched almost 3,812 meters above sea level, is the world’s highest navigable lake by large boats. Its clear waters straddle the border between Peru and Bolivia in the Andes. ✨
#lakes⚡#Andes⚡#altitude⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 In Africa’s Lake Natron, minerals in the water turn it bright red during the dry season. The lake’s extreme chemistry preserves animal remains, creating eerie natural “statues.” ✨
#lakes⚡#Africa⚡#chemistry⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The world’s clearest lake is Blue Lake in New Zealand. Its pure water is so transparent that objects can be seen up to 80 meters below the surface—almost like looking through glass. ✨
#lakes⚡#water⚡#clarity⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Finland boasts about 188,000 lakes, earning it the nickname "Land of a Thousand Lakes." Many of these lakes were formed by retreating glaciers at the end of the last Ice Age. ✨
#lakes⚡#glaciation⚡#Finland⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels