Ранее я уже упоминал о другой фишке из ˍˍ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
🪐 NASA’s Psyche mission is sending a high-tech spacecraft to the asteroid 16 Psyche, testing a new electric propulsion system called Hall thrusters. Hall thrusters use electricity and magnetic fields to accelerate charged particles (ions) for thrust, offering a more efficient way to travel long distances—demonstrating key technology that could power spaceships to worlds like Ceres or the moons of Jupiter in the future. ✨
#spaceships⚡#propulsion⚡#asteroids⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 NASA’s Deep Space Transport concept envisions a future spaceship designed to carry astronauts between Earth and Mars, using advanced solar electric propulsion for long-distance travel. Unlike chemical rockets, solar electric propulsion uses sunlight to generate electricity and power ion engines, allowing spacecraft to efficiently accelerate over months as they approach destinations like the Red Planet. ✨
#spaceships⚡#Mars⚡#propulsion⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The future of interstellar travel may hinge on new propulsion ideas being studied today, like nuclear electric propulsion—which uses nuclear reactors to generate electricity for ultra-efficient ion engines. NASA has tested this kind of technology in missions like Deep Space 1, and scientists hope that one day, such systems could send spacecraft toward distant stars like Proxima Centauri far faster than chemical rockets ever could. ✨
#spaceships⚡#propulsion⚡#ProximaCentauri⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 NASA's Psyche mission, launched in 2023, is using solar electric propulsion—an advanced spaceship technology that turns sunlight into electricity to power ion thrusters. Psyche’s journey to the metallic asteroid 16 Psyche will take it over 3.5 billion kilometers, marking one of the longest deep-space flights ever attempted using this efficient, future-ready form of space travel. ✨
#spaceships⚡#innovation⚡#propulsion⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The future of interstellar travel could harness the power of antimatter propulsion, a technology based on using matter and antimatter (mirror-opposite particles) that annihilate each other to release immense energy. Experiments at places like CERN have shown how much energy is produced when particles like protons and antiprotons meet—a reaction far more powerful than any chemical rocket, making antimatter a real contender for traveling to distant stars such as Proxima Centauri in the distant future. ✨
#spaceships⚡#antimatter⚡#propulsion⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The challenge of reaching other star systems like Proxima Centauri, over 4 light-years away, drives scientists to explore futuristic spaceship concepts beyond anything in use today. One promising idea is fusion propulsion, which would harness the power of fusing atomic nuclei—just like in the Sun—to generate immense thrust, potentially making journeys to nearby stars possible in a matter of decades rather than millennia. ✨
#fusion⚡#propulsion⚡#spaceships⚡#ProximaCentauri⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels