Ранее я уже упоминал о другой фишке из ˍˍ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
📈Wheat Price Outlook: Navigating Volatility & Key Levels
Wheat markets are currently experiencing a period of volatility, driven by a complex interplay of weather patterns, geopolitical factors, and market structure. This article delves into the current...
🔗Read Full Analysis
🎯 SPECIAL OFFER: 15% OFF
💸 Coupon Code: salenow15%
🚀 Upgrade to premium signals → https://markets.fxpremiere.com/en/signals?utm_source=telegram
#Commodities#Wheat#FuturesTrading
🚀 CoinEx Futures Trial Fund — Trade Futures Risk-Free!
Want to experience real futures trading without risking your own money? CoinEx Futures Trial Fund is here to help you get started confidently.
🔹 What is Futures Trial Fund?
CoinEx Futures Trial Fund is a risk-free trading voucher that lets users practice futures trading in real market conditions. It can be used as margin and to cover trading fees, funding fees, and even losses.
🌟 Why Choose CoinEx Futures Trial Fund?
✅ Zero initial capital
✅ Real futures trading experience
✅ Profits are fully withdrawable
Perfect for beginners and experienced traders who want to test strategies without pressure.
📘Step-by-step guide:
🔥 The Futures Trial Fund has just been upgraded — don’t miss the chance to trade futures with zero risk and real rewards!
#CoinEx#FuturesTrading#TrialFund
MicroStrategy(@Strategy) bought another 1,895 $BTC($180.34M) at an average price of $95,167 last week.
#Strategy currently holds 555,450 $BTC($52.35B), with an average buying price of $68,550 and an unrealized profit of $14.28B.
#CryptoSignals#FuturesTrading#VIPGroup#BTC#Altcoins#CryptoProfit