В стандартном модуле random есть две очень похожие функции
random.randint()
random.randrange()
Обе возвращают случайное значение из указанного диапазона
>>> random.randint(10, 20)
12
>>> random.randrange(10, 20)
17
В чем же отличие?
Дело в том что у randrange() есть третий параметр step.
randint() действительно возвращает случайное число из указанного диапазона.
randrange() на первый взгляд делает тоже самое если передать также два параметра.
Но есть указать еще и step то наш диапазон усложняется, то есть в него попадёт не полный ряд значений.
Например, я хочу получить случайное значение из диапазона но только чётное число. Тогда достаточно сделать так:
>>> randrange(10, 20, 2)
16
Таким образом получается что randint это частный случай randrange без указания параметра step.
Еще одно важное отличие в том, что randint() включает в диапазон второе значение а randrange() нет. То есть выражение randrange(10, 20) никогда не вернёт 20, а randint(10, 20) вернёт.
#tricks#basic
Indices Nasdaq US30 Signals Live News Today – 6th April 2026 https://www.fxpremiere.com/indices-nasdaq-us30-signals-live-news-today-6th-april-2026/#us30signals Make Money Online - FxPremiere Group
Live Indices News Today – US30, NASDAQ, NAS100 & GER40 | March 24, 2026 https://www.fxpremiere.com/live-indices-news-today-us30-nasdaq-nas100-ger40-march-24-2026/#US30#us30signals
Live Indices News Today – US30, NAS100, NASDAQ & GER40 | March 16, 2026 https://www.fxpremiere.com/live-indices-news-today-us30-nas100-nasdaq-ger40-march-16-2026/#US30#us30signals@followers
Live Crypto News Today — Digital Asset Market Update 28th Jan, 2026 https://www.fxpremiere.com/live-crypto-news-today-digital-asset-market-update-28th-jan-2026/#us30signals#NAS100 Make Money Online - FxPremiere Group
Live Crypto News Today — Digital Asset Market Update 28th Jan, 2026 https://www.fxpremiere.com/live-crypto-news-today-digital-asset-market-update-28th-jan-2026/#us30signals#NAS100 Make Money Online - FxPremiere Group
Indices Nasdaq US30 Signals Live News Today – 7th April 2026 https://www.fxpremiere.com/indices-nasdaq-us30-signals-live-news-today-7th-april-2026/#indices#us30signals
Signals Forecast for Indice News Signals Starting 28th April 2026: US30, NAS100, S&P 500, FOMC Day One, AI Earnings, Oil Risk and Live Trading Scenarios https://www.fxpremiere.com/signals-forecast-for-indice-news-signals-starting-28th-april-2026-us30-nas100-sp-500-fomc-day-one-ai-earnings-oil-risk-and-live-trading-scenarios/#US30#us30signals#NAS100
Signals Forecast for Indices News Starting 22nd April 2026: US30, NAS100, S&P 500 Outlook, U.S. Macro Risks, and Live Trading Scenarios https://www.fxpremiere.com/signals-forecast-for-indices-news-starting-22nd-april-2026-us30-nas100-sp-500-outlook-u-s-macro-risks-and-live-trading-scenarios/#indices#US30#us30signals
Indice Signals News Forecast for US30 NASDAQ NAS100 GER40 Starting 16th April 2026 https://www.fxpremiere.com/indice-signals-news-forecast-for-us30-nasdaq-nas100-ger40-starting-16th-april-2026/#indices#US30#us30signals#NAS100 Make Money Online - FxPremiere Group
Live Indices News — US30, NAS100, GER40 & Global Markets
February 13, 2026 https://www.fxpremiere.com/live-indices-news-us30-nas100-ger40-global-markets-february-13-2026/#indices#US30#us30signals#NAS100 FxPremiere Group Nasdaq Financial Times
Indices Forecast — Week Ahead (9–13 February 2026) https://www.fxpremiere.com/indices-forecast-week-ahead-9-13-february-2026/#indices#US30#us30signals#NAS100 Nasdaq
Live Indices Signals News Today – US30, Nasdaq & Global Markets | April 2, 2026 https://www.fxpremiere.com/live-indices-signals-news-today-us30-nasdaq-global-markets-april-2-2026/#US30#us30signals#NASDAQ